I'm using ASP.NET MVC5 and VS2013

I've tried to copy CodeTemplates folder from

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VWDExpress\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates

with subfolders "AddController", "AddView" and T4 templates inside them, then I modified some templates, but nothing happened when I tried to add View nor Controller..

2016年03月31日32分07秒

First, it looks like you have Visual Studio 2013 and 2012 both installed on your computer. I tried looking up the path you provided, I couldn't find it. On your path it looks like you're trying to use MVC4 templates. Here is my path:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\
Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates

Below is how I customized my scaffold template for the BaseController:

  1. Create folder called "CodeTemplates" directly in the project folder.

  2. Go to below path, find MvcControllerWithActions folder copy all to folder "CodeTemplates"

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\
    Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates
  3. Go to CodeTemplates -> MvcControllerWithActions in your project.

  4. There are two files, Controller.cs.t4 and Controller.vb.t4 in MvcControllerWithActions, if you used C#, you can delete Controller.vb.t4.

  5. Open the Controller.cs.t4 file, modify the Controller name to BaseController, like below:

    public class <#= ControllerName #> : BaseController
    {
    }
  6. Now, when you try to create MVC5 Controller using "add new scaffold item", it'll use the template you customized.

Hope it helps.

2016年03月31日32分07秒

The MVC5 T4 templates are located in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\VWDExpressExtensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcView

2016年03月31日32分07秒

MVC4 and MVC5 templates are located in different locations. While MVC4 templates are located in the folder you've given, MVC5 templates are located in this folder:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates

What you need to do for customizing is to create a folder named CodeTemplates your project folder, and copy the templates you want to customize to the CodeTemplates folder.

You'll need to copy MvcView and MvcControllerWithContext folders in order to use with MVC 5 Controller with view, using EntityFramework command.

CAUTION

  • Both directories must have the same folder structure. What I mean is, do not copy the Create.cs.t4in the MvcView folder directly into the CodeTemplates folder. Just copy the entire MvcView folder intoCodeTemplates folder.

  • Do not delete include files such as Imports.include.t4 and ModelMetadataFunctions.cs.include.t4because other files need them to be there.

  • If you're using C#, feel free to delete files with .vb.t4 extension and vice versa.

2016年03月31日32分07秒

如何创建自定义ASP.NET MVC5脚手架模板?的更多相关文章

  1. ASP.NET MVC5 +Abp 模板(Startup Templates)

    官网:https://aspnetboilerplate.com/Templates 系统登陆初始账号:admin 密码:123qwe 调试错误: 1.在多语句事务内不允许使用 CREATE DATA ...

  2. 在ASP.NET MVC5 及 Visual Studio 2013 中为Identity账户系统配置数据库链接及Code-First数据库迁移

    在ASP.NET MVC5 及 Visual Studio 2013 中为Identity账户系统配置数据库链接及Code-First数据库迁移 最近发布的ASP.NET MVC 5 及Visual ...

  3. ASP.NET MVC5 PagedList分页示例

    ASP.NET MVC是目前ASP.NET开发当中轻量级的Web开发解决方案,在ASP.NET MVC概述这篇译文当中,已经详细的介绍了ASP.NET MVC与Web Forms的区别以及各自的适用场 ...

  4. vs 2013下自定义ASP.net MVC 5/Web API 2 模板(T4 视图模板/控制器模板)

    vs 2013下自定义ASP.net MVC 5/Web API 2  模板(T4 视图模板/控制器模板): Customizing ASP.NET MVC 5/Web API 2 Scaffoldi ...

  5. 五、 创建连接串连接本地数据库(ASP.NET MVC5 系列)

    1. 创建连接串连接本地SQLServer数据库 上节讲到MovieDBContext类,这个类的作用是连接数据库并将Movie对象迁移到数据库记录中.不过你会问一个问题:如何知道这个对象将连接哪个数 ...

  6. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](一)

    前言 大家好,我是Rector 从今天开始,Rector将为大家推出一个关于创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar]的文章系列, ...

  7. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](十)

    前言 朋友们, 大家好,我还是Rector,写ASP.NET MVC 5系列文章[一步一步创建ASP.NET MVC5程序Repository+Autofac+Automapper+SqlSugar] ...

  8. 在 ASP.NET MVC 中创建自定义 HtmlHelper

    在ASP.NET MVC应用程序的开发中,我们常碰到类似Html.Label或Html.TextBox这样的代码,它将在网页上产生一个label或input标记.这些HtmlHelper的扩展方法有些 ...

  9. 一步一步创建ASP.NET MVC5程序[Repository+Autofac+Automapper+SqlSugar](五)

    前言 Hi,大家好,我是Rector 时间飞逝,一个星期又过去了,今天还是星期五,Rector在图享网继续跟大家分享系列文本:一步一步创建ASP.NET MVC5程序[Repository+Autof ...

随机推荐

  1. JZ2440串口打印字符作为调试

    /* * 初始化UART0 * 57600,8N1,无流控 */ void uart0_init(void) { GPHCON |= 0xa0; // GPH2,GPH3用作TXD0,RXD0 GPH ...

  2. android自定义控件(理论知识学习 +自定义属性的讲解)

    View树和UI界面架构图   UI界面架构图: android视图最外层是一个window对象. phoneWindow来实现. phoneWindow将一个decorView作为整个布局的根vie ...

  3. CentOS6.2编译gcc失败,kernel-headers错误

    准备转移到阿里云服务器,用的CentOS6.2 x64,虚拟机上用的 6.3版本,测试重装了好几次都没问题了,结果在云服务器上刚开始就出问题了... yum 安装的时候居然出错了,靠...网上 goo ...

  4. js-常用数组方法总结

    [前面的话]说数组“万能”,可能夸张了一点,但是就个人观点,数组的运用是非常广泛的,这里的广泛当然也包含了在其他语言中的运用.举例说明,在javascript当中,由于字符串的不可变性,在进行字符串拼 ...

  5. 推荐一篇很好的介绍wpf dependency property的文章

    http://www.codeproject.com/Articles/140620/WPF-Tutorial-Dependency-Property

  6. wamp,phpserver,xampp环境冲突

    这几天在使用laravel5.2时 执行:php artisan migrate [PDOException] could not find driver 分析可能是以下情况造成 1 php.ini配 ...

  7. GROUP_CONCAT()多条数据.拼接字符串 最大长度1024

    mysql cmd show variables like "group_concat_max_len"; concat  合并多条数据 成一个逗号分隔的字符串 查找mysql的配 ...

  8. IOS 类似网易新闻客户端内容滚动菜单跟随居中组件

    需求分析: 1.类似网易新闻客户端页面滚动组件.菜单栏对应菜单项一直居中 2.点击菜单栏可以切换到对应的page 3.滑动页面可以自动切换相应的菜单.并且对应的菜单栏居中显示 4.初始化时可以自定义菜 ...

  9. SharePoint 2013 列表启用搜索

    转载自:http://www.cnblogs.com/jianyus/p/3470117.html SharePoint 2013列表搜索的设置,只是进行完全爬网,就可以使用.如果开启爬网不是很熟练可 ...

  10. C++ inline和#define宏的区别

    (1)什么是内联函数? 内联函数是指那些定义在类体内的成员函数,即该函数的函数体放在类体内. (2)为什么要引入内联函数?当然,引入内联函数的主要目的是:解决程序中函数调用的效率问题.另外,前面我们讲 ...