entity-frameworkdbcontextobjectcontext

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


Background

Problem / Question

Now. The EDMX (TT transform, custom tool, whatever, etc.) is generating BOTH DbContext classes (under the Model.tt/Model.Context.tt files) and ObjectContext classes (via the Model.designer.cs file). See image below:

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

Everything builds fine and works with the DbContext (but obviously only if I delete the Designer.cs file just before building) but the Designer.cs - and its ObjectContext-based code - keeps reappearing. How do I stop this behavior?!


Solution

  • I didn't find out how to stop the Designer.cs file from generating the ObjectContext, but I did figure out how to make it so that it doesn't matter. Just set the Build Action to "None" instead of "Compile".

    Set the Build Action to None