尝试使用 MVCScaffolding 创建视图时出现问题

发布于 2024-12-06 12:25:18 字数 419 浏览 7 评论 0原文

注意:我已查看此链接并禁用了 CustomTools,但仍然收到此错误: ​​MvcTextTemplateHost not found

我是尝试在一个命令中为创建、更新、详细信息、过滤器和列表操作创建自定义视图。我可以通过右键单击并选择“新视图”一次添加它们,但是当我输入 Scaffold AddView SampleModel 时,我收到以下错误消息:

无法找到类型或命名空间名称“MvcTextTemplateHost”(是否缺少使用指令还是程序集引用?)。

模板文件是AddView.cs.t4。我尝试将其重命名为 .tt 但无法让 Powershell 查找 .tt 文件。有什么想法吗?

NOTE: I have looked at this link and disabled CustomTools and still receive this error: MvcTextTemplateHost not found

I am trying to create custom Views in one command for Create, Update, Details, Filter, and List operations. I am able to add them one at a time by right clicking and choosing New View, but when I type Scaffold AddView SampleModel I get the following error message:

The type or namespace name 'MvcTextTemplateHost' could not be found (are you missing a using directive or an assembly reference?).

The template file is AddView.cs.t4. I tried renaming it to .tt but I cannot get the Powershell to look for a .tt file. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青春有你 2024-12-13 12:25:18

MvcScaffolding 使用自己的自定义模板宿主,不使用 MvcTextTemplateHost。我会看一下 MvcScaffolding NuGet 包 中包含的 T4 模板。这些模板之一的开头如下所示。

<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
<#@ Output extension="aspx" #>
<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>

MvcScaffolding uses its own custom template host and does not use the MvcTextTemplateHost. I would take a look at the T4 templates that are included with the MvcScaffolding NuGet package. The beginning of one of these templates is shown below.

<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
<#@ Output extension="aspx" #>
<# var viewDataType = (EnvDTE.CodeType) Model.ViewDataType; #>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文