Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NEW T4 Controller Template in MVC3

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:

enter image description here

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?

like image 498
Saeid Avatar asked Oct 07 '22 15:10

Saeid


1 Answers

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.

like image 60
nemesv Avatar answered Oct 12 '22 12:10

nemesv