在 ASP.NET Core 中查看脚手架模板 [英] View scaffold templates in ASP.NET Core
本文介绍了在 ASP.NET Core 中查看脚手架模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
MVC 5 在创建视图时具有非常方便的功能,可以选择用于构建视图的模板.这使用 T4 模板文件生成基于指定类型的 CSHTML 文件.
MVC 5 has the very handy feature when creating a view to be able to select a template for scaffolding out the view. This uses a T4 template file to generate a CSHTML file based on a specified type.
有没有办法在 ASP.Net Core 1.0 中做这样的事情?
Is there a way to do anything like this in ASP.Net Core 1.0?
推荐答案
您需要在 Tools 上添加引用.但仅限于构建时间
You need to add references on Tools. But only for build time
在 project.json
中,将以下内容添加到 dependencies
部分:
in project.json
, add the following to the dependencies
section:
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
}
仍然在 project.json
中,找到 tools
部分并添加以下内容
Still in project.json
, locate the tools
section and add the following
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
这篇关于在 ASP.NET Core 中查看脚手架模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文