如何修复 Entity Framework 4.1 模型模板中缺失的类型/命名空间错误?
我有一个 T4 模板来为支持我的 .edmx
模型的实体生成 C# 类。模板以此标头开头:
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#>
尝试构建项目会导致这些错误
error CS0234: The type or namespace name 'Design' does not exist in the namespace 'System.Data.Entity'...
error CS0246: The type or namespace name 'EnvDTE' could not be found (are you missing a using directive...
error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'...
我该如何修复此问题?
I have a T4 template to generate C# classes for the entities backing my .edmx
model. The template starts with this header:
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#>
Attempting to build the project results in these errors
error CS0234: The type or namespace name 'Design' does not exist in the namespace 'System.Data.Entity'...
error CS0246: The type or namespace name 'EnvDTE' could not be found (are you missing a using directive...
error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'...
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,基于 VS扩展性线程,问题的原因是
Clarius Visual T4 扩展。它在
.csproj
中重置此节点方案
解决
是手动将
.csproj
文件中的节点更改为None
。改变它通过 Visual Studio 属性编辑器返回
.tt
文件不起作用。最后,禁用扩展可以防止这种情况再次发生。
It turns out than, based on a VS Extensibility thread, the reason for the problem was
the Clarius Visual T4 extension. It reset this node in the
.csproj
file to
from
The solution is to manually change the node to
None
in the.csproj
file. Changing itback via the Visual Studio properties editor for the
.tt
file does not work.Finally, disabling the extension prevents this from happening again.
只需在
.tt
文件的开头添加所需的程序集即可;像这样:Just simply add needed assemblies at the beginning of your
.tt
file; like this: