How to rename Context.tt generated by Entity Framework?

entity-framework

Question

We're using Entity Framework 5 model first design. We decided to rename the .edmx file but the MyModel.Context.tt and MyModel.tt files can't be renamed. The File Name property is read only and I can't find a reference to the file name elsewhere. Anyone know how to rename them?

1
18
12/13/2012 3:50:59 AM

Popular Answer

The work-around seems to be to let it generate the .tt files as it wants. Rename the .edmx. When you rename the edmx, there are references to the .edmx in the .tt files which don't get changed either. You could edit the .tt files to reference the new name for the .edmx, but that doesn't rename the .tt files, so instead delete both .tt files. Go to the .edmx diagram, right-click and add code generation item. Choose a DBContext generator, name it as you please, and click "add". Bob is now your uncle.

Per this, the inability to rename seems to be desired behavior: http://entityframework.codeplex.com/workitem/523

JR

29
11/20/2017 12:03:46 PM


Related Questions





Related

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