NEW T4 Controller Template in MVC3

无人久伴 提交于 2019-12-21 05:09:14

问题


As you know to create new t4 templates in MVC, need to add CodeTemplates folder to project. There are two main subfolders 1-AddController, 2-AddView I always use AddView folder to add new templates to generate custom views, know I need new template to generate controllers, but when I add new tt file to AddController folder, there is no any new option in templates of new controller, there is always 3 options:

So how can I add new option to Add Controller window to use my custom Controller Template? Or if I try wrong way, what is your suggestion to use Template to generate controllers?


回答1:


It seems you can only extend the Add Controller dialog with using the MvcScaffolding nuget package:

From the 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!

You can start learning about MvcScaffolding from this article.



来源:https://stackoverflow.com/questions/10913824/new-t4-controller-template-in-mvc3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!