Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename Context.tt generated by Entity Framework?

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?

like image 361
NullReference Avatar asked Dec 13 '12 03:12

NullReference


1 Answers

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

like image 162
jrv Avatar answered Sep 28 '22 07:09

jrv