In Visual Studio 2013 RTM there is no support for adding completely custom scaffolders. You can only do the following customizations:
- You can edit or override the existing T4 templates for controllers, areas, views, etc.
- You can add custom view scaffolders that will show up in the existing MVC View scaffolder
The Visual Studio team is working on re-enabling custom scaffolder support in a future update of Visual Studio.
To add a custom view scaffolder today:
- Create any ASP.NET project in VS2013
- Add a folder called
CodeTemplates
- Create a sub-folder in there called either
MvcView
or MvcViewWithoutModel
depending on whether your custom view template is a strongly-typed view
- Create a file there in the form of
<templatename>.<lang>.t4
where the <templatename>
is whatever you want to show up in the MVC View scaffolder's drop down list and <lang>
is either cs
or vb
.
To get started you can copy any existing scaffolder from VS2013's default list and customize it. You can get the built-in scaffolders from here:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcView
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcViewWithoutModel
If you use the same name as an existing scaffolder then it will override the built-in scaffolder, even when called from another scaffolder. For example, the MVC controller scaffolder will use an overridden view scaffolder that is in your project.
4/22/2014 Update
Now that previews of Visual Studio 2013 Update 2 are available, it is possible to write completely custom scaffolders.
Check out this blog post that walks through how to write a custom scaffolder: Creating a Custom Scaffolder for Visual Studio