MVC3 中的新 T4 控制器模板 [英] NEW T4 Controller Template in MVC3

查看:25
本文介绍了MVC3 中的新 T4 控制器模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所知,要在 MVC 中创建新的 t4 模板,需要将 CodeTemplates 文件夹添加到项目中.有两个主要的子文件夹 1-AddController, 2-AddView 我总是使用 AddView 文件夹添加新模板来生成自定义视图,知道我需要生成控制器的新模板,但是当我将新的 tt 文件添加到 AddController 文件夹时,新控制器的模板中没有任何新选项,总是有 3 个选项:

As you know to create new t4 templates in MVC, need to add CodeTemplates folder to project. There are two main subfolders 1-AddController, 2-AddView I always use AddView folder to add new templates to generate custom views, know I need new template to generate controllers, but when I add new tt file to AddController folder, there is no any new option in templates of new controller, there is always 3 options:

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

So how can I add new option to Add Controller window to use my custom Controller Template? Or if I try wrong way, what is your suggestion to use Template to generate controllers?

推荐答案

看来您只能使用 MvcScaffolding nuget 包:

It seems you can only extend the Add Controller dialog with using the MvcScaffolding nuget package:

来自 asp.net 页面:

ASP.NET MVC 3 工具更新包括强大的 Visual Studio 支持对于这个脚手架系统,例如:

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

  • 添加控制器对话框现在支持创建、读取、更新和删除控制器动作和相应的全自动脚手架意见.默认情况下,此脚手架使用 EF Code 来构建数据访问代码首先.
  • 添加控制器对话框通过 NuGet 包(例如 MvcScaffolding)支持可扩展脚手架.这允许插入自定义脚手架进入对话框,这将允许您创建脚手架对于其他数据访问技术,例如 NHibernate 甚至 JET如果您愿意,请使用 ODBCDirect!

你可以开始学习 MvcScaffolding 来自本文.

You can start learning about MvcScaffolding from this article.

这篇关于MVC3 中的新 T4 控制器模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆