I'm having a reacurring problem with deploying my websites. Everything works perfectly locally but when I upload my projects I get the following error on any page that requires a database connection:
Server Error in '/' Application.
Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.276
I'm using EF code-first during development. I then recreate those databases for SQL 2008 in MSSMS and upload a backup of those to the database I create on the hosts servers. Dynamic database creation on the host is not possible due to access rights. The
project files I upload by publishing all project files in VS.
I've been trying various approaches to solve this for several weeks, but none have worked so far. I think the error started after an update in the VS 11 RC, but I'm not certain.
These are some of the things I've been trying so far:
- The host I'm using offers the 4.0 .NET framework, so I've modified my projects to use that framework rather than the current 4.5.
- I've tagged System.Data and System.Data.Entity 'Copy Local' to true.*
- Copied all the /bin files from an older project, that seems to work but a number of other errors popp up then. And I don't like the idea of having to rely on having to manually upload some outdated bin files for future projects.
- Tried stripping down web.config to the very minimum (trial and error tweaking really).
I'm not very proficient when it comes to server configurations and website publishing yet, so I really hope somebody here is able to help me somewhat.
Any help is appreciated,
sincerely, Hrafninn.
*ps. I should mention that my projects do not include a reference to System.Data.Objects, nor could I find any such framework to include in the projects.
based on the issue you raised, it seems that you did not properly publish your site.
Please do the followings:
1. Please open your project with VS tool 2. On the Solution Explorer window, right click your project and select "Publish" 3. Please publish your project to a local folder, e.g. C:\Project 4. Once you publish your files to this folder, you just need to upload whatever files you see on C:\Project via FTP to the server and I guarantee everything will work If you like to host your website, you can consider asphostcentral.com as your hosting provider
Please mark this response as an "answer" if it helps you. Thanks heaps!
Quote "Newer version (the real EF5) is dependent on .NET 4.5. If you have added EF5 when your project was based on .NET 4.0 you will have only EF 4.4 (EF5 version without features dependent on .NET 4.5). After upgrading to EF 5.0 you need to update EntityFramework
package. You can try to use
Update-Package
command. If it doesn't help you will need to uninstall package first and than add it again."
Ladislav Mrnka
Where I had been going wrong was by creating new projects using .NET 4.5, then later changing those to .NET 4.0. The problem with changing the platform aimed for after creation rather than setting it for .NET 4.0 during creation is that the Entity Framework
included with the project then becomes EF 5. This does not change when downgrading the .NET framework used.
So the uploaded files for the EF would require .NET 4.5 to work, hence the missing method error.
So the steps it took that solved the problem were:
1) Create new project, and set it to .NET 4.0 on creation.
2) This then automatically includes EF 4.4.0 (instead of EF 5), which as mentioned in the quote above is EF 5 minus all the parts that require .NET 4.5.
3) Rebuild project.
4) Publish again.
After this everything is working online as it does locally,
Sincerely, Hrafninn.
Marked as answer by Hrafninn on Sep 12, 2012 12:06 AM
Instead of creating a new project you can uninstall EF5 and then reinstall EF4.4 on your existing project with nuget ... with your target framework set to 4.0 it will grab the correct version
uninstall-package entityframework
> on success
install-package entityframework
Deploy and you should be good to go ... Just ran into this issue and this resolved it. Thanks for your post!
Hrafninn
0 Points
3 Posts
Method not found after deployment (System.Data.Objects).
Sep 07, 2012 05:53 PM|LINK
Hello,
I'm having a reacurring problem with deploying my websites. Everything works perfectly locally but when I upload my projects I get the following error on any page that requires a database connection:
Server Error in '/' Application.
Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: Method not found: 'Void System.Data.Objects.ObjectContextOptions.set_UseConsistentNullReferenceBehavior(Boolean)'.
Source Error:
Stack Trace:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.276
I'm using EF code-first during development. I then recreate those databases for SQL 2008 in MSSMS and upload a backup of those to the database I create on the hosts servers. Dynamic database creation on the host is not possible due to access rights. The project files I upload by publishing all project files in VS.
I've been trying various approaches to solve this for several weeks, but none have worked so far. I think the error started after an update in the VS 11 RC, but I'm not certain.
These are some of the things I've been trying so far:
- The host I'm using offers the 4.0 .NET framework, so I've modified my projects to use that framework rather than the current 4.5.
- I've tagged System.Data and System.Data.Entity 'Copy Local' to true.*
- Copied all the /bin files from an older project, that seems to work but a number of other errors popp up then. And I don't like the idea of having to rely on having to manually upload some outdated bin files for future projects.
- Tried stripping down web.config to the very minimum (trial and error tweaking really).
I'm not very proficient when it comes to server configurations and website publishing yet, so I really hope somebody here is able to help me somewhat.
Any help is appreciated,
sincerely, Hrafninn.
*ps. I should mention that my projects do not include a reference to System.Data.Objects, nor could I find any such framework to include in the projects.
necro_mancer
Star
8089 Points
1590 Posts
Re: Method not found after deployment (System.Data.Objects).
Sep 08, 2012 07:26 AM|LINK
based on the issue you raised, it seems that you did not properly publish your site.
Please do the followings:
1. Please open your project with VS tool
2. On the Solution Explorer window, right click your project and select "Publish"
3. Please publish your project to a local folder, e.g. C:\Project
4. Once you publish your files to this folder, you just need to upload whatever files you see on C:\Project via FTP to the server and I guarantee everything will work
If you like to host your website, you can consider asphostcentral.com as your hosting provider
Please mark this response as an "answer" if it helps you. Thanks heaps!
Professional SQL 2008 R2 Service
Hrafninn
0 Points
3 Posts
Re: Method not found after deployment (System.Data.Objects).
Sep 08, 2012 02:22 PM|LINK
Thank you for the reply necro,
Unfortunately that didn't seem to work,. I tried the following:
1) Publish to local HDD location, FTP from there with "files included in the project".
2) Publish to local HDD location, FTP form there with "all files in project folders".
3) FTP the whole directory where I keep the project files for the website.
None of these worked, I'm still getting the same error.
Any other ideas?
Sincerely, Hrafninn.
Hrafninn
0 Points
3 Posts
Re: Method not found after deployment (System.Data.Objects).
Sep 12, 2012 12:05 AM|LINK
I solved it!
I found out that Entity Framework 5 does not work with ASP.NET 4.0.
http://stackoverflow.com/questions/12368304/entityframework-5-use-dll-version-4-4-0-instead-5-0
Quote "Newer version (the real EF5) is dependent on .NET 4.5. If you have added EF5 when your project was based on .NET 4.0 you will have only EF 4.4 (EF5 version without features dependent on .NET 4.5). After upgrading to EF 5.0 you need to update EntityFramework package. You can try to use
command. If it doesn't help you will need to uninstall package first and than add it again."Ladislav Mrnka
Where I had been going wrong was by creating new projects using .NET 4.5, then later changing those to .NET 4.0. The problem with changing the platform aimed for after creation rather than setting it for .NET 4.0 during creation is that the Entity Framework included with the project then becomes EF 5. This does not change when downgrading the .NET framework used.
So the uploaded files for the EF would require .NET 4.5 to work, hence the missing method error.
So the steps it took that solved the problem were:
1) Create new project, and set it to .NET 4.0 on creation.
2) This then automatically includes EF 4.4.0 (instead of EF 5), which as mentioned in the quote above is EF 5 minus all the parts that require .NET 4.5.
3) Rebuild project.
4) Publish again.
After this everything is working online as it does locally,
Sincerely, Hrafninn.
ajzeffer
Member
2 Points
1 Post
Re: Method not found after deployment (System.Data.Objects).
Feb 06, 2013 06:06 PM|LINK
Instead of creating a new project you can uninstall EF5 and then reinstall EF4.4 on your existing project with nuget ... with your target framework set to 4.0 it will grab the correct version
uninstall-package entityframework
> on success
install-package entityframework
Deploy and you should be good to go ... Just ran into this issue and this resolved it. Thanks for your post!