简体   繁体   English

与更新实体数据模型(.edmx)有关的问题

[英]Issue related to Updating Entity Data Model (.edmx)

I have an asp.net web Application. 我有一个asp.net Web应用程序。 I have added Entity Data Model in the App_Code folder, that generates the following files : 我在App_Code文件夹中添加了Entity Data Model ,它生成以下文件:

  1. Model.Context.tt
  2. Model.edmx
  3. Model.tt

In Model.tt there is Model.cs file, that contains Partial classes of selected tables. Model.tt有一个Model.cs文件,其中包含所选表的Partial类。

Now when I try to update the .edmx file to add a new table, Model.cs is not getting updated, it does not add the new class for newly added table. 现在,当我尝试更新.edmx文件以添加新表时, Model.cs不会得到更新,因此不会为新添加的表添加新的类。

How to update Model.cs file when any new table or update existing table in Model.edmx ? 当有新表或更新Model.edmx现有表时,如何更新Model.cs文件?

Thanks 谢谢

This issue generally appears when our .edmx file is present in a folder in the project. 当项目的文件夹中存在我们的.edmx文件时,通常会出现此问题。 Generally I was able to solve the issue by right clicking the .edmx file and then selecting Run Custom Tool option. 通常,我可以通过右键单击.edmx文件,然后选择Run Custom Tool选项来解决此问题。 In some cases you will need to do the same for Context.tt and .tt file also. 在某些情况下,您还需要对Context.tt.tt文件执行相同的操作。

In few weird cases when I tried adding/editing columns of an existing table, to update the entity file, I had to open the .cs file inside the .tt file and then the run Run Custom Tool on .tt file. 在少数奇怪的情况下,当我尝试添加/编辑现有表的列以更新实体文件时,我不得不打开.tt文件中的.cs文件,然后对.tt文件运行Run Custom Tool ”。 It almost worked every time I edited an existing table and entity files were updated successfully. 每次我编辑现有表并成功更新实体文件时,它几乎都能正常工作。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新ado.net实体数据模型而不影响EDMX中已经存在的模型类 - Updating ado.net entity data model without effecting model classes already in EDMX Edmx 实体模型继承 - Edmx Entity model inheritance 更新实体框架中的相关数据 - updating related data in entity framework 如何从实体数据模型(edmx)生成数据上下文类? - How to generate data context class from entity data model (edmx)? 创建第二个EDMX文件永远不会运行实体数据模型向导 - Creating a second EDMX file never runs the Entity Data Model Wizard 使用 Entity Framework Core 更新相关数据 - Updating related data with Entity Framework Core 使用MVC 5中的Entity Framework 6更新相关数据 - Updating related Data with Entity Framework 6 in MVC 5 使用MVC 4和Entity Framework更新相关数据吗? - Updating related data using MVC 4 and Entity Framework? 在不更新Database First Entity Framework MVC应用程序中的其他模型的情况下,向模型(edmx)添加新表 - Adding a new table to model (edmx) without updating the other models in Database First Entity Framework MVC application 更新edmx模型后,DbContext怎么样? - After updating edmx model, what about DbContext?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM