Change default pages created by MVC in Visual Studio C#

Asked

Viewed 85 times

2

When I create the controller and use MVC 5 Controller with views, using Entity Framework, the Index, Create, Edit, Delete and Details are created automatically with a default setting, and I have to include a new class to change the css button.

I would like to know if there is any way for these pages to always use a custom mode.

  • 2

    This link will help you: https://www.c-sharpcorner.com/UploadFile/4fcb5a/step-by-step-implementing-t4-custom-templates-in-mvc5-projec/

  • Perfect, this is exactly what I was looking for. Thank you.

1 answer

1


I wonder if there is any way that these pages always use a custom mode.

Yes, there is. You can use T4 Templates Visual Studio to customize automatic generation of Views of a specific project.

The way with these templates can change according to Visual Studio version:

{VS_PATH} Common7 IDE Extensions Microsoft Web Mvc Scaffolding Templates

Read this content for a detailed step-by-step how to customize templates for an MVC5 project.

Below is a summary of the steps:

  1. Create a folder in your project with the name 'Codetemplate' and copy to it all the contents of the Templates folder passed above.
  2. Build from the Solution.
  3. Find in the copied content (Cs.T4 files) the snippets you want to customize. Note: Folder names indicate the generation being changed

Browser other questions tagged

You are not signed in. Login or sign up in order to post.