如何在 ASP.NET MVC 3 中创建自己的脚手架模板? [英] How do I create my own Scaffold Template in ASP.NET MVC 3?
问题描述
ASP.NET MVC 提供了选择脚手架模板"的能力,新创建的视图将基于该模板(添加视图 > 创建强类型视图 > 脚手架模板).
ASP.NET MVC provides the ability to select a 'Scaffold template' upon which a newly-created view will be based (Add View > Create a strongly-typed view > Scaffold template).
是否可以创建自己的脚手架模板?如果是这样,如何?
Is it possible to create your own Scaffold Template? And if so, how?
推荐答案
ASP.NET MVC 使用 T4 模板.这里是概述.
ASP.NET MVC uses T4 templates. Here's an overview.
步骤如下:
- 在包管理器控制台中输入:
install-package mvc3codetemplatescsharp
- 接受所有警告
CodeTemplates
文件夹将添加到包含模板的项目中
- In the Package Manager Console type:
install-package mvc3codetemplatescsharp
- Accept all the warnings
- The
CodeTemplates
folder will be added to your project containing the templates
从这里您可以修改现有模板或添加新模板.
From here you could either modify the existing templates or add new one.
或者如果你想全局修改那些你可以在 C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEItemTemplatesCSharpWebMVC 3CodeTemplates
文件夹.
Or if you want to modify those globally you could to this in the C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEItemTemplatesCSharpWebMVC 3CodeTemplates
folder.
这篇关于如何在 ASP.NET MVC 3 中创建自己的脚手架模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!