[英]Entity Framework doesn't create Context and table classes(.cs) from Entity Data Model (from existing database) in MVC
I have an ASP.Net MVC Project and Existing database.When I add new item -> ADO.Net Entity Data Model, it gives me the model (Model1.edmx including 4 files in it Model1.Context.tt
, Model1.Designer.cs
, Model1.edmx.diagram
, Model1.tt
) but it doesn't create my .cs files and DbContext file.我有一个 ASP.Net MVC 项目和现有数据库。当我添加新项目 - > ADO.Net 实体数据模型时,它为我提供了模型(Model1.edmx 包括其中的 4 个文件
Model1.Context.tt
、 Model1.Designer.cs
、 Model1.edmx.diagram
、 Model1.tt
)但它不会创建我的 .cs 文件和 DbContext 文件。 When I click Update Model From Database it gives me two errors:当我单击从数据库更新模型时,它给了我两个错误:
"CompanyProject\Models\Model1.Context.tt.
Error message is The custom tool 'TextTemplatingFileGenerator' failed."
CompanyProject\Models\Model1.tt.
Error message is The custom tool 'TextTemplatingFileGenerator' failed.**
Can you help me?你能帮助我吗?
我通过以下方式修复了它:更改自定义工具属性:.edmx 属性 -> 高级 -> 自定义工具:TextTemplatingFileGenerator
I ran into this problem some day ago, and I fixed it by doing:前几天我遇到了这个问题,我通过以下方式解决了这个问题:
Right click on .Context.tt file -> run custom tool, try it many time and before retry build and clean your project右键单击 .Context.tt 文件 -> 运行自定义工具,尝试多次,然后重试构建和清理项目
Hope this help.希望这有帮助。
Leo狮子座
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.