How do I stop Entity Framework from generating BOTH ObjectContext and dbContext

dbcontext entity-framework objectcontext



  • using Visual Studio 2012
  • MODEL NEW. VS2012 generated an EDMX file.
  • I imported portions of the EDMX xml from an earlier EDMX I had written.

Issue or Question

Now. Both DbContext classes and ObjectContext classes are generated by the EDMX (TT transform, custom tool, etc.) and stored in the files (via the Model.designer.cs file). the photo below

Both the AND the Designer.cs files are defining my entities

The Designer.cs file and its ObjectContext-based code keep resurfacing, yet everything compiles and functions with the DbContext absolutely fine (though clearly only if I erase it just before building). How can I stop doing this?

10/25/2012 6:00:25 PM

Accepted Answer

I was unable to figure out how to stop the Designer.cs file from creating the ObjectContext, but I was able to make it irrelevant. Simply change "Compile" to "None" in the Build Action field.

Set the Build Action to None

10/25/2012 6:17:20 PM

Popular Answer

The .tt Regardless of the code generation approach used in the files, the.edmx . They take in the.edmx file alterations At least for me, they are functioning in this way.

the code generating technique is changed toNone in the.edmx You choose the.designer.cs file without any valuable information.

then access the project file and look for the nodes that reflect the.edmx thus it is automatically included inEntityDeploy delete its node, i.e. the Build Action value.Generator subkey.

Related Questions


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