英文:
Visual Studio 17.6.1 Update: EF6 no longer generating classes
问题
Visual Studio 更新,Entity Framework 6,Windows 10。
我将 Visual Studio 更新到版本 17.6.1 后,当我重新创建我的 EF 模型(数据库优先)时,没有生成任何类。
在更新之前,这个操作正常工作。
我尝试重新安装 VS 和 EF,但没有生成任何类。
非常感谢任何帮助。
英文:
Visual Studio Update, Entity Framework 6, Windows 10.
I updated Visual Studio to Version 17.6.1 and when I recreate my EF model (DB First) none of the classes are generated.
This worked fine right before the update.
I tried reinstalling VS as well as EF, but none of the classes are generated.
Any help much appreciated.
答案1
得分: 1
- 我遇到了相同的问题。
- 我在<b>EF6.Utility.CS.tt.include</b>文件中进行了一次修改。
- 在编辑之前,请复制此文件,以防您想要还原。
- 它的位置在这里:"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes"文件夹中。
- 在第1920行更改前的代码:
private DynamicTextTransformation(object instance)
{
_instance = instance;
Type type = _instance.GetType();
_write = type.GetMethod("Write", new Type[] { typeof(string) });
_writeLine = type.GetMethod("WriteLine", new Type[] { typeof(string) });
_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic);
_host = type.GetProperty("Host");
_errors = type.GetProperty("Errors");
}
- 在第1920行更改后的代码:
_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
- 所以只需添加"| BindingFlags.Public"。
英文:
- I had the same issue.
- I made a single change in the <b>EF6.Utility.CS.tt.include</b> file.
- Make a copy of this file before editing it, just in case you want to revert.
- Its location is here: "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes" folder.
- Code before line 1920 change:
private DynamicTextTransformation(object instance)
{
_instance = instance;
Type type = _instance.GetType();
_write = type.GetMethod("Write", new Type[] { typeof(string) });
_writeLine = type.GetMethod("WriteLine", new Type[] { typeof(string) });
_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic);
_host = type.GetProperty("Host");
_errors = type.GetProperty("Errors");
}
- Code after line 1920 change:
_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
- So only add " | BindingFlags.Public"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论