DbContext Generator - configuring for model in another namespace
With ref开发者_JAVA技巧erence to EF 4.1 DbContext Generattor - Put Entities in different project? , what is required to get the DbContext to use the entities in another namespace? Do I need to edit the the DbContext template (and if so, how?) or do I need to edit the .edmx?
You should edit the EDMX-file reference in your T4-template file (.tt) and just save. It will show you a dialog.
Open the .tt-file and look for the following line:
string inputFile = @"your-edmx-filename.edmx;
So change it so that it will point to the EDMX of the other project:
string inputFile = @"..\Other-projects-folder\your-edmx-filename.edmx;
This approach is used in order to separate the DbContext / ObjectContext from the generated entities and make it i.e. part of your DAL which is a much better fit since it deals with your database.
精彩评论