Hi @mc
From your description, you want to custom scaffold templates in ASP.NET Core, right? If that is the case, you can refer to this tutorial: Custom scaffold templates in ASP.NET Core, or refer to the following steps:
By default, the code generators template is in this folder - %USERPROFILE%\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\6.0.6\Templates
(the number 6.0.6 will change based on the SDK version).
- Create a Asp.net core Razor or MVC project.
- In your project, you can create a folder with name
Templates
, then copy the templates from the default folder to your project folder. Then, modify the templates in your project and modify the project file like this.
<ItemGroup>
<Compile Remove="Templates\**" />
<Content Remove="Templates\**" />
<EmbeddedResource Remove="Templates\**" />
<None Remove="Templates\**" />
</ItemGroup>
- Use this command to install the dotnet-aspnet-codegenerator:
dotnet tool install -g dotnet-aspnet-codegenerator
- using the command to install the
Microsoft.VisualStudio.Web.CodeGeneration.Design
nuget package to the project:
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
- Open the project folder in File Explorer. Right click the project and select the "Open Folder in File Explorer" option. Then, delete the
bin
andobj
folder, after that rebuild the project. - Now we can scaffold the controller using the following command, it will generate pages based on the custom templates:
dotnet-aspnet-codegenerator controller -name ExampleController -outDir Controllers --no-build
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion