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:
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?!
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".
The .tt
files will generate the code regardless of the code generation strategy in the .edmx
. They listen to the .edmx
file changes. At least this is how they are working for me.
So by turning the code generation strategy to None
in the .edmx
you make the .designer.cs
file empty of any useful content.
Then open up the project file, find the nodes representing the .edmx
, by default it is contained in EntityDeploy
node ie the Build Action value, and remove its Generator
subkey.
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