asp.net-mvc - MVC3 中的新 T4 Controller 模板

标签 asp.net-mvc asp.net-mvc-3 controller t4 code-templates

如您所知,要在 MVC 中创建新的 t4 模板,需要添加 CodeTemplates项目的文件夹。有两个主要的子文件夹 1- AddController , 2- AddView我总是用 AddView添加新模板以生成自定义 View 的文件夹,知道我需要新模板来生成 Controller ,但是当我添加新模板时 tt文件到 AddController文件夹,新 Controller 的模板中没有任何新选项,总是有3个选项:

enter image description here

那么如何向“添加 Controller ”窗口添加新选项以使用我的自定义 Controller 模板?
或者,如果我尝试错误的方式,您对使用模板生成 Controller 的建议是什么?

最佳答案

似乎您只能使用 MvcScaffolding 扩展“添加 Controller ”对话框。 nuget 包:

来自 asp.net page :

The ASP.NET MVC 3 Tools Update includes great Visual Studio support for this scaffolding system, such as:

  • Add Controller Dialog now supports full automatic scaffolding of Create, Read, Update, and Delete controller actions and corresponding views. By default, this scaffolds data access code using EF Code First.
  • Add Controller Dialog supports extensible scaffolds via NuGet packages such as MvcScaffolding. This allows plugging in custom scaffolds into the dialog which would allow you to create scaffolds for other data access technologies such as NHibernate or even JET with ODBCDirect if you’re so inclined!


可以开始学习MvcScaffolding from this article .

关于asp.net-mvc - MVC3 中的新 T4 Controller 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10913824/

相关文章:

javascript - Angular typescript Controller 中的“状态未定义”

javascript - ajax 调用成功后更改 @Html.DisplayFor 项目

c# - 单击按钮时逐个添加对象 MVC C#

c# - 同时使用继承和依赖注入(inject)

asp.net - 从 WebForms 调用 ASP.NET MVC3 区域

Javafx 只初始化 Controller 构造函数一次?

javascript - Getting Object does not support this action 错误 on $.post

asp.net-mvc-3 - 在 MVC 3 中使用编辑器模板和 EditorFor 时动态添加行

unit-testing - MVC3 中的单元测试 Controller session 变量

authentication - Play Framework : How to require login for some actions, 但不是全部