Custom scaffold templates in ASP.NET Core

Rono picture Rono · Jul 14, 2016 · Viewed 15.9k times · Source

Now that I figured out how to enable scaffolding in ASP.NET Core MVC (see View scaffold templates in ASP.NET Core), I'd like to create custom template files for Views. I found one place that said the template files are located here:

C:\Users\{user name}\.dnx\packages\Microsoft.Extensions.CodeGenerators.Mvc\1.0.0-rc1-final\Templates\ViewGenerator

But I copied an existing file there and that copied file does not appear in the Template dropdown on the Add View dialog. Are they located elsewhere, or do I have to do something to get files added in that folder to appear? Restarting Visual Studio did not do that.

Answer

user3012633 picture user3012633 · Sep 15, 2016

I am using Microsoft.VisualStudio.Web.CodeGeneration.Tools 1.0.0-preview2-final

Templates are located here...

C:\Users\{username}\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\1.0.0-preview2-final\Templates

Copy the Templates folder to your project and edit them as required.

enter image description here