[英]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
,它生成以下文件:
Model.Context.tt
Model.edmx
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.