加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – MVC3中的新T4控制器模板

发布时间:2020-12-16 03:27:32 所属栏目:asp.Net 来源:网络整理
导读:如您所知,在MVC中创建新的t4模板,需要将CodeTemplates文件夹添加到项目中.有两个主要子文件夹1-AddController,2-AddView我总是使用AddView文件夹添加新模板来生成自定义视图,知道我需要新模板来生成控制器,但是当我将新的tt文件添加到AddController文件夹时,
如您所知,在MVC中创建新的t4模板,需要将CodeTemplates文件夹添加到项目中.有两个主要子文件夹1-AddController,2-AddView我总是使用AddView文件夹添加新模板来生成自定义视图,知道我需要新模板来生成控制器,但是当我将新的tt文件添加到AddController文件夹时,没有任何新控制器模板中的新选项,总有3个选项:

那么如何在Add Controller窗口中添加新选项以使用我的自定义控制器模板?
或者,如果我尝试错误的方式,您有什么建议使用模板生成控制器?

解决方法

看来你只能使用 MvcScaffolding nuget包扩展Add Controller对话框:

从asp.net page开始:

The ASP.NET MVC 3 Tools Update includes great Visual Studio support
for this scaffolding system,such as:

  • Add Controller Dialog now supports full automatic scaffolding of Create,Read,Update,and Delete controller actions and corresponding
    views. By default,this scaffolds data access code using EF Code
    First.
  • Add Controller Dialog supports extensible scaffolds via NuGet packages such as MvcScaffolding. This allows plugging in custom
    scaffolds into the dialog which would allow you to create scaffolds
    for other data access technologies such as NHibernate or even JET with
    ODBCDirect if you’re so inclined!

您可以开始学习MvcScaffolding from this article.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读