8
votes

Previously, with Visual Studio 2012, I was able to bring the CodeTemplates folder up to my project directory and then modify the existing T4 templates or add entirely new T4 templates to meet my particular code generation requirements.

It seems that the previously described approach will no longer work with the new scaffolding engine introduced with Visual Studio 2013. In particular, it seems that the new scaffolding logic resides here:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding

and I'm assuming that you need to build a new custom scaffolding DLL and register it with Visual Studio to do your own flavour of code generation. Of course, I have no idea how to do this.

So, does anyone know of a way to generate code (e.g. Views) using custom T4 templates in Visual Studio 2013?

2
Why can't you bring over your old T4 templates from VS2012? T4 is still a part of VS2013.Just another metaprogrammer
Well in VS2012 it used to be the case that you could Right-click -> Add View/Controller, and then specify the Scaffold Template you'd like to use. At that point, you'd either choose one of the default templates, or one of the custom templates you added to a CodeTemplates folder within your project directory. As far as I can tell with VS2013, you have no way of accessing the previous Add View/Controller dialogs where you could specify your own Scaffold Template. Rather, you can now only select from one of the pre-built templates that ships with VS2013 via Add -> Scaffold...Sean
Have You found some more information about custom scaffolding in VS2013?LockTar

2 Answers

11
votes

It's fixed in the RC. You can now use the CodeTemplates folder. Just create the CodeTemplates folder in app root and paste the templates there. More at,
Customizing ASP.NET MVC 5/Web API 2 Scaffolding Templates in Visual Studio 2013

1
votes

according to another post: Here, you can now write a custom scaffolder.

Here is the msdn link : Creating a Custom Scaffolder for Visual Studio