在Visual Studio 2017中添加EF 6.x EntityObject Generator [英] Add EF 6.x EntityObject Generator in Visual Studio 2017

查看:386
本文介绍了在Visual Studio 2017中添加EF 6.x EntityObject Generator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们计划切换到Visual Studio 2017. 对于我们的Entity Framework 6 edmx文件,我们使用 EntityObject Generator扩展来创建我们所需的ObjectContext.

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.

此扩展程序最多仅与VS2013兼容-非正式地直到VS2015.不过,在VS2017中似乎无法简单地在vsix中调整清单文件的解决方案-我猜尤其是因为vsix架构发生了变化.

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.

有没有一种方法可以在不使用旧的Visual Studio的情况下获取ObjectContext模板?我认为每个edmx文件的模板都不总是相同的,因此可以简单地从现有项目中复制粘贴.

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.

推荐答案

我刚刚在VS2017中做到了.

I just did this in VS2017.

从MS下载VS扩展软件包用于C#的EF 6.x EntityObject Generator".这是一个* .VSIX文件.将其重命名为ZIP.打开zip文件,然后在其中找到另一个zip. 在那里,您将看到一个TT文件.复制出来.

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.

在您的项目中,具有生成DbSet的MyModel.TT文件,只需将该TT文件替换为从vsix文件获得的TT文件即可.

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.

编辑一行:

    SourceCsdlPath = @"$edmxInputFile$",

到您的

    SourceCsdlPath = @"myEDM.emdx",

保存TT文件,并且您的c#模型代码是使用旧的EntityObjects生成的

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

这篇关于在Visual Studio 2017中添加EF 6.x EntityObject Generator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆