At work we just upgraded to Entity Framework 5. Our EDMX file now has a couple other nodes beneath it:
EntityContainer.Context.tt
which contains the generated DbContext object and
EntityContainer.tt
which contains the entities themselves.
For a short period, adding an entity in EF was automatically regenerating the tt (T4 Templates) when we would save the EDMX file. Now all of a sudden we have to right-click the T4 templates and select “Run Custom Tool” to get them to regenerate the .cs files for the context or entities.
Any ideas how this might have happened?
Update
In the EDMX the property “Transform Related Text Templates On Save” is set to true and the problem is still happening.
Is your EDMX in a sub-folder of your project? If so, the good news is that you didn’t do anything wrong. The bad news is that this is a known issue…check my blog post about it. http://thedatafarm.com/blog/data-access/watch-out-for-vs2012-edmx-code-generation-special-case/.
Two work arounds for the time being:
1) move the edmx into the main project folder
2) explicitly force the code gen as needed