Question

I need to custumize the scaffolding templates in asp.net mvc5. But I could not find the related the files.

Also is it possible to put paging or export options to scafffolding template ?

Regards.

Was it helpful?

Solution

Below is how I customized my scaffold template for the BaseController. You can customize more templates by follow these steps and pick up the right template you want to customize.

  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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top