Custom Scaffolding Templates in Visual Studio 2013
Asked Answered
C

2

8

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?

Cognac answered 13/8, 2013 at 1:54 Comment(3)
Why can't you bring over your old T4 templates from VS2012? T4 is still a part of VS2013.Sarah
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...Cognac
Have You found some more information about custom scaffolding in VS2013?Hug
J
11

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

Johanajohanan answered 15/9, 2013 at 18:23 Comment(1)
How do you get the CodeTemplates to display in your Add dialogs in Visual Studio 2013? I had read the following: [hanselman.com/blog/… [1]: hanselman.com/blog/… When going to Add New Item dialog they don't show up.Bethesda
L
1

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

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

Lick answered 24/4, 2015 at 17:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.