Search code examples
asp.net-mvc-scaffolding

MVC Scaffolding View using custom template


I have created a custom template as follows:

Scaffold CustomTemplate View Index

As a result, I now have a local T4 template:

enter image description here

I made some modifications to the template. My question is how to generate code only for the view. I have done the following which works but which in my opinion is overkill since all I want is for my view to be generated.

Scaffold Controller -ModelType Task -ControllerName TasksController -DbContextType TasksDbContext -Repository -Force

Solution

  • I've managed to find out what command to pass:

    Scaffold View -ModelType Task -Controller Tasks -ViewName Index -Template Index -Force
    

    What I didn't know about was the -Template string switch.