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