Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using ASP.NET MVC5 and VS2013

I've tried to copy CodeTemplates folder from

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VWDExpress\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates

with subfolders "AddController", "AddView" and T4 templates inside them, then I modified some templates, but nothing happened when I tried to add View nor Controller..

share|improve this question
    
I've dug around a bit and haven't found a way to customize the scaffolding system. –  Alex Dresko Nov 17 '13 at 23:06
add comment

3 Answers

up vote 10 down vote accepted

First, it looks like you have Visual Studio 2013 and 2012 both installed on your computer. I tried looking up the path you provided, I couldn't find it. On your path it looks like you're try to use MVC4 templates. Here is my path:

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

Below is how I customized my scaffold template for the BaseController:

1)Create folder call "CodeTemplate" directly in the project folder.

2)Go to below path, find MvcControllerWithActions folder copy all to folder "CodeTemplates"

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

3)Go to CodeTemplates -> MvcControllerWithActions in your project.

4)There are two files, Controller.cs.t4 and Controller.vb.t4 in MvcControllerWithActions, if you used C#, delete Controller.vb.t4.

5)Open the Controller.cs.t4 file, modify the Controller name to BaseController, like below:

 public class <#= ControllerName #> : BaseController
    {
    }

6) Now, when you try to create MVC5 Controller using "add new scaffold item", it'll use the template you customized.

Hope it helps.

share|improve this answer
1  
Thanks, it works well! I my case I'm using VSExpress, so actual path is: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VWDExpressExtensions\Microsoft\Web\Mvc\Scaffolding\Templates –  Roman Nov 18 '13 at 8:04
    
Funny, mine are located at: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\1033 –  Eric B Feb 17 at 2:47
    
1033? WHy doesn't my folder have Scaffolding/Templates? Weird –  Eric B Feb 17 at 2:48
add comment

i am trying to make custom view templates using kendo UI grid using scaffolding with entity framework 6.0 in an mvc 5 web app.

i can not really understand what is happening.

i did what you mentioned above but nothing is happening. my view is generated as it is on default despite i changed everything in the template. why is that happening and how the custom templates are working

share|improve this answer
add comment

The MVC5 T4 templates are located in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VWDExpressExtensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcView

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.