Entity Framework 5 stopped launching T4 template files while saving

At work, we just upgraded to Entity Framework 5. Our EDMX file now has a couple of other nodes:

EntityContainer.Context.tt 

which contains the generated DbContext object and

 EntityContainer.tt 

which contains the entities themselves.

For a short period of time, adding an object to EF automatically restored tt (T4 Templates) when we saved the EDMX file. Now we suddenly need to right-click on the T4 templates and select β€œRun Custom Tool” so that they can restore .cs files for context or entities.

Any ideas how this could happen?

Update

In EDMX, the "Transform Related Text Templates On Save" property is set to true, and the problem is still happening.

+4
source share
2 answers

Is your EDMX in a subfolder of your project? If so, the good news is that you haven’t done anything wrong. The bad news is that this is a known issue ... check out my blog post about this. http://thedatafarm.com/blog/data-access/watch-out-for-vs2012-edmx-code-generation-special-case/ .

Currently two works:

1) move edmx to the main project folder 2) explicitly force the generation of gen code if necessary

+6
source

In fact, there is another option for a workaround. I found this error because I upgraded EF 4 EDMX to EF 5 by adding the EF 5.x DbContext Generator to the EF 5.x DbContext Generator , which added T4 templates to the existing EDMX.

However, in the project file, he did not mark them as a DependentUpon EDMX file, so they did not appear under the EDMX node. Instead, they appeared side by side with the EDMX in the folder. T4 generation worked fine until I manually entered and added DependentUpon nodes to the project file.

Please note: http://www.youtube.com/watch?v=-boB5GhqfUI

+3
source

Source: https://habr.com/ru/post/1438514/


All Articles