简体   繁体   中英

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. 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

Hope this help.

Leo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM