实体框架5停在节省运行T4模板文件停在、实体、框架、节省

2023-09-03 17:44:51 作者:王者为她战天下

在工作中我们刚刚升级到实体框架5.我们的EDMX文件现在有它下面几个其他节点:

At work we just upgraded to Entity Framework 5. Our EDMX file now has a couple other nodes beneath it:

EntityContainer.Context.tt

,其中包含所生成的DbContext对象以及

which contains the generated DbContext object and

EntityContainer.tt

包含实体本身。

which contains the entities themselves.

有关在短期内,将在EF实体被自动再生TT(T4模板)时,我们会保存EDMX文件。现在,突然之间,我们必须用鼠标右键单击该T4模板,然后选择运行自定义工具,让他们重新生成的.cs文件上下文或实体。

For a short period, adding an entity in EF was automatically regenerating the tt (T4 Templates) when we would save the EDMX file. Now all of a sudden we have to right-click the T4 templates and select "Run Custom Tool" to get them to regenerate the .cs files for the context or entities.

任何想法如何这可能发生?

Any ideas how this might have happened?

在EDMX属性改造相关文件的模板保存时设置为true,问题仍然发生。

In the EDMX the property "Transform Related Text Templates On Save" is set to true and the problem is still happening.

推荐答案

是您的EDMX在项目中的子文件夹?如果是这样,好消息是,你并没有做错什么。坏消息是,这是一个已知的问题......检查我的博客文章了。 http://thedatafarm.com/blog/data-access/watch-out-for-vs2012-edmx-$c$c-generation-special-case/.

Is your EDMX in a sub-folder of your project? If so, the good news is that you didn't do anything wrong. The bad news is that this is a known issue...check my blog post about it. http://thedatafarm.com/blog/data-access/watch-out-for-vs2012-edmx-code-generation-special-case/.

两种解决暂且:

1)移动EDMX到主项目文件夹 2)明确为需要分力C根的$ C $

1) move the edmx into the main project folder 2) explicitly force the code gen as needed