开发者

DbContext Generator - configuring for model in another namespace

开发者 https://www.devze.com 2023-03-22 05:10 出处:网络
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 th

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消