Entity Framework References go missing between debug and release build

c# console-application entity-framework-6

Question

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.

1
8
6/2/2015 12:58:59 PM

Accepted Answer

Switching to release mode then re-installing entity framework on the problem project fixed this issue in my case.

6
8/20/2015 6:19:06 AM

Popular Answer

To resolve this I used @OomPiet's answer. For me the steps were as follows:

  1. Switch to Debug Mode
  2. Rebuild solution - Build Successful
  3. Switch to Release Mode
  4. Rebuild solution - Build Failed
  5. In Solution Explorer click on the project that will not build (mine was a unit test project)
  6. Right Click project > Manage NuGet Packages
  7. Ensure Installed packagesis selected
  8. Select EntityFramework
  9. Click Uninstall and close dialog
  10. Click on Solution in Solution Explorer
  11. Right Click > Manage NuGet Packages for Solution
  12. Ensure Installed packagesis selected
  13. Select EntityFramework
  14. Click Manage
  15. Ensure the project which is causing issue is checked
  16. Click OK and close dialog after installing
  17. Click Click on Solution in Solution Explorer
  18. Right Click 'Rebuild Solution'

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.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow