How do I edit default Razor Creat/Edit scaffolding

2019-03-31 03:19发布

is there a way I can hack out the fieldset and legend tags in the VS2010 MVC razor view templates?

I've had a bit of a look through the C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE directory but I can't find what I'm looking for.

2条回答
手持菜刀,她持情操
2楼-- · 2019-03-31 04:00

Sounds like you'll need to download the source for MVC 3.0 and copy the templates you want to overwrite into you project and make the changes there.

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-31 04:05

If it is specific to your project, what you can do is copy the default templates to  your project and modify them.

The MVC razor view templates are located in:

<Visual Studio Installation Path>\Common7\IDE\ItemTemplates\CSharp\Web\MVC 3\CodeTemplates
\AddView\CSHTML\
  1. Copy the .tt files

  2. Create a matching folder tree in your project starting from CodeTemplates. In this case,  you need to create \CodeTemplates\AddView\CSHTML\ and paste the .tt files there.

  3. Now you can edit the .tt files as you want. When you crete a new view in that project, those templates will  be used instead of the default ones from the installation folder. That also works for the controller templates, you just have to make sure that the folder  tree matches.
查看更多
登录 后发表回答