Customizing ASP.NET MVC 5/Web API 2 Scaffolding Templates in Visual Studio 2013
Introduction:
Scaffolding in ASP.NET allows you to automatically generate code in web application. This make it easy to quickly add boilerplate code in your application. There is a nice introduction of scaffolding in ASP.NET application using Visual Studio 2013 at here. The default templates are good for a lot of cases, but sometimes you want to customize these scaffolding templates for all your applications and sometimes you need to use different scaffolding templates in different projects. In this article, I will show you how to customize the default scaffolding t4 templates in ASP.NET MVC 5 and ASP.NET Web API 2 globally and per project.
Description:
If you need to customize the scaffold templates globally then just navigate to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates (depending upon where Visual studio reside),
In the above explorer, you can globally update the t4 templates of ASP.NET MVC 5 and ASP.NET Web API 2.
Now for per project base, just create a CodeTemplates folder in your application root and paste the above folders inside CodeTemplates folder,
You can read more about this at here.
Summary:
In this article, I showed you how you can easily customize the default code generation(scaffolding) templates in ASP.NET MVC 5 and ASP.NET Web API 2 using Visual Studio 2013. Hopefully you will enjoy my this article too.