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. cuda8.0环境下安装py-faster-rcnn问题总结

    首先声明,由于之前安装的cuda8.0,在实践中出现各种问题,这里不是指安装环境问题,而是在训练模型是会阻止内核启动,因此让我不得不转战8.0,说出来都是泪啊,配个环境都配了一个礼拜了,所以,请不要轻 ...

  2. JEMETER 录制

    两种方式: 第一种:badboy工具录制,导入jemeter脚本,导入jemeter.目测支持IE 第二种:代理服务器的方式 1.

  3. 第一百零六节,JavaScript变量作用域及内存

    JavaScript变量作用域及内存 学习要点: 1.变量及作用域 2.内存问题 JavaScript的变量与其他语言的变量有很大区别.JavaScript变量是松散型的(不强制类型)本质,决定了它只 ...

  4. hdu_5324_Boring Class(cdq分治+树状数组)

    题目链接:hdu_5324_Boring Class 题意: 给出n个二维点对,求LIS长度和编号字典序最小的LIS(x非增,y非减) 题解: dp[i]=max(dp[j]) (i>j,l[i ...

  5. Highest Rated Features

  6. jQuery实例1

    1.选择器: <body> <script src="jquery-2.2.4.js"></script> <div id="n ...

  7. Qt4.8.x Linux WebKit依赖库安装

    yum install "pkgconfig(gstreamer-app-0.10)"

  8. 使 httpClient 支持中文

    一个有效的方法:重载 PostMethod 的 getRequestCharSet 方法 1: class PostChinese { 2: HttpClient httpClient = new H ...

  9. I Think I Need a Houseboat

    I Think I Need a Houseboat Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java ...

  10. 通过实例来理解ajax

    点击一个按钮,然后将信息显示到指定的div内. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"& ...