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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With