1
votes

I want to customize the scaffolding template for .NET Core 3.1 . I am unable to find the location of scaffolding template for ASP.NET Core 3.1. I searched a lot but all searches ends up for .NET Core 2.1.

Further following location does not work for me,

C:\Program Files (x86)\Microsoft Visual Studio\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates 
C:\Program Files (x86)\Microsoft Visual Studio\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates
C:\Users\<user>\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\3.1.4\Templates

I changed the template in above locations but they are not reflecting whenever I create new item.

2

2 Answers

3
votes

If you want to custom scaffolding template in your project,you can do like this:

Firstly,copy the Templates folder to your project: enter image description here

Then change the Tempaltes in the folder,and create scaffold item in the project,it will work.(In .net core,add a new template to it,it will not work,you can only modify the default templates by the way)

Here is a demo:

I changed the Create.cshtml in Templates/ViewGenerator(it's a .net core mvc project,so I deleted Identity,Identity_Versioned,RazorPageGenerator,RazorPageGenerator_Versioned folder):

enter image description here

I change

enter image description here

to

enter image description here

result: enter image description here

0
votes

You can see in

enter image description here

For example:

C:\Users\MyName\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc

If you need a programable way: https://devblogs.microsoft.com/aspnet/creating-a-custom-scaffolder-for-visual-studio/