ASP.NET MVC uses T4 Templates to generate controllers and views. When you add a controller or view to an ASP.NET MVC Web Application, the default controllers and views are generated via T4 Templates that sit in a directory within the Visual Studio Item Templates Directory on your PC.
The location of the Code Templates Folder varies depending on your environment, but here is an example:
- - Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Item Templates\CSharp\Web\Mvc...
If you are a big fan of code generation, you will want to exploit the opportunity to customize those T4 Templates with common coding conventions that you use to build ASP.NET MVC Web Applications.
One of my personal best practices is to copy the Code Templates folder into the ASP.NET MVC Web Application. There are two advantages to this practice:
- - Code Generation Productivity - When you copy the Code Templates folder into your ASP.NET MVC Web Application, the Add View and Add Controller Menu Options use these local templates instead of the global templates for generating controllers and views. This means that any changes you make to the local templates are reflected in the new controllers and views generated in your application. Customize these templates for big productivity gains.
- - Source Control - Adding these templates to your solution means that you can store these templates in source control to be used by your whole team. Thus, your whole team can take advantage of the code productivity of the custom T4 Templates.
To take advantage of these templates, copy the Code Templates Folder to your local ASP.NET MVC Web Application's Root Directory:

You will notice the T4 Templates that generate the views and controllers in your ASP.NET MVC Applications.
After you add this folder you will need to remove the TextTemplatingFileGenerator as the Custom Tool from each of the templates. The TextTemplatingFileGenerator is unnecessary as ASP.NET MVC will generate the views and controllers personally.

Now you can customize the controllers and views with any custom coding conventions that you use in your ASP.NET MVC Controllers and Views.
The Tampa ASP.NET MVC Developer Group has a screencast that shows you how to leverage these per-project custom T4 Templates in your applications for maximum productivity:
Next time you create a new ASP.NET MVC Web Application, customize the code generation T4 Templates to improve your productivity.

Good Article.. I have been recently looking into this sort of thing..
I noticed when using Item Templates that if you create say a custom control (.ascx) file of the same name as one that already exists e.g: Overview.ascx the code behind file can error.
Instead of creating a Partial Class called say 'Overview1' it references 'Overview' which already exists for the other control and can therefore cause conflicts..
Anyone have a way around this? It has mean't I don't use Item templates at the moment..
Posted by: Mark Henderson | 11/23/2009 at 02:47 AM
It sounds like you are not talking about Code Templates, Display Templates, or Editor Templates in ASP.NET MVC, but the ability to create project and item templates in Visual Studio? Not sure how to get Visual Studio to change it to your desired behavior. You may want to check the Visual Studio Preferences to see if there is a setting.
Posted by: David Hayden | 11/24/2009 at 07:42 AM