There must be something that I don't understand in the difference between debug builds and release builds and its use of references. I'm using Entity Framework 6 to connect to a database that has previously been set up. I am able to successfully build and run the project while it is in Debug mode. If I change it to release mode I instantly get build errors indicating that the namespaces and types that were just there can no longer be found. I checked and as far as I can tell they both target framework .Net 4.5 which I saw may have been an issue for some other people. I see no difference in what is listed under references in my solution explorer.
I'm using visual studio 2013. Happy to provide any code but I don't know what would be most relevant.
Some of the errors that I'm getting:
The type or namespace name 'Entity' does not exist in the namespace System.Data' (are you missing an assembly reference?) in Holds.Context.cs
The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) in Holds.Context.cs
The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?) in Holds.Context.cs
Thanks for any guidance that can be provided.
To resolve this I used @OomPiet's answer. For me the steps were as follows:
Solution Explorer
click on the project that will not build (mine was a unit test project)Manage NuGet Packages
Installed packages
is selectedEntityFramework
Uninstall
and close dialogSolution Explorer
Manage NuGet Packages for Solution
Installed packages
is selectedEntityFramework
Manage
checked
OK
and close dialog after installingSolution Explorer
Now I can switch between Debug
and Release
without compilation failing. I hope that helps
EDIT: If you have only one project using EF, see @LuckyLikey's comment below where he states to search for EF instead, and install it in that project.
Switching to release mode then re-installing entity framework on the problem project fixed this issue in my case.
Ok @Dim and @Oompiet's answers are correct but there's a really easy way to do this via the Package Manager Console:
Update-Package -reinstall EntityFramework
That will do it at the Solution level or if you want to do it at the project level just do:
Update-Package -reinstall EntityFramework -p <YouProjectName>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With