In VS 2010 and EF 4.4, you were able to move and edit .tt files when using the DBContext generator in Entity Framework such that your POCO objects where in a different project than your DBContext files.
In VS2012 / EF5 this seems not to be possible. the POCO classes are generated as a subitem under the EDMX file. The files cannot be copied from within Visual Studio. Moving the files from Explorer does not help because the files you moved get recreated at compilation time.
Am I missing something basic here?
I am not using any code generation items with EF5 (whereas I was with EF4.x.) Could that be the difference?
In Visual Studio 2012, when you add an ADO.NET Entity Data Model (*.edmx), it includes the T4 templates for the context and model classes as sub-items of the EDMX file. For example, if you add MyModel.edmx, it will have 4 sub-items as follows:
MyModel.tt generates the POCO entities as sub-items. To generate the entities in a separate project, follow the following steps:
Edit the template file as follows:
const string inputFile = @"MyModel.edmx"; // old value (remove) const string inputFile = @"..\MyOtherProjectName\MyModel.edmx"; // new value
That's it. You're done. You now have your model and context in one project and the entities in a separate project.
Check out the following post: Visual Studio 2012 - Can't move EF .tt files
It speaks to how you can remove the dependency information of the .tt file to the .edmx file within the assoicated .csproj file. This will then allow you to drag the .tt file from within Solution Explorer.
Just make sure to update the file path in the begining of the .tt file to point to the .edmx as described in the previous answer and shown below:
const string inputFile = @"..\EFTest\EFTestModel.edmx";
There are actual several pieces and steps and missing any single one can prevent the separation of the POCO classes from working correctly. I created a blog post that details the entire process that you can view below:
Separating Entity Framework POCO Classes Generated From T4 Template in VS.NET 2012: