Add EF 6.x EntityObject Generator in Visual Studio 2017

…衆ロ難τιáo~ 提交于 2020-01-23 12:25:08

问题


We are planning to switch to Visual Studio 2017. For our Entity Framework 6 edmx file we use the EntityObject Generator extension to create us the desired ObjectContext.

This extension is only compatible up to VS2013 - inofficially up to VS2015. The solution to simply adjust the manifest file in the vsix does not seem to work for VS2017 though - I guess among others because the vsix architecture changed.

Is there a way to get the ObjectContext template without using an old Visual Studio? I assume the template is not always the same for each edmx file so it could simply be copy pasted from an existing project.


回答1:


I just did this in VS2017.

Download the VS extension package "EF 6.x EntityObject Generator for C#" from MS. It's a *.VSIX file. Rename it to ZIP. open the zip file and inside that you find one more zip. There you will see a TT file. Copy it out.

In your project that have a MyModel.TT file that generates DbSet just replace that TT file with the one you got from vsix file.

Edit one line:

    SourceCsdlPath = @"$edmxInputFile$",

to your

    SourceCsdlPath = @"myEDM.emdx",

save TT file and your c# model code is generated with old EntityObjects



来源:https://stackoverflow.com/questions/46241084/add-ef-6-x-entityobject-generator-in-visual-studio-2017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!