在ASP.net MVC中首先使用实体​​框架数据库一次性支持所有模型 [英] Scaffold all the models in ASP.net MVC using entity framework database first at one go

查看:65
本文介绍了在ASP.net MVC中首先使用实体​​框架数据库一次性支持所有模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft提供了一个很酷的功能,可以使用模板脚手架生成控制器和视图,你可以通过右键单击控制器的文件夹来实现,比如添加控制器和添加然后可以指定数据上下文类,模态和然后选择模板并单击Add buttton以生成相应的控制器和强类型视图,但是我们可以自动执行此过程,这样我就不必为每个模态手动完成上述步骤,而是我们可以拥有一些用于生成控制器的自定义模板和一次性所有模态的视图?





Mayank Singh

Microsoft has provided a cool feature for generating controller and views using scaffolding of templates and you can do it by just right clicking on the controller''s folder, say add controller and add then can specify the data context class,modal and then select template and click on Add buttton to generate the respective controllers and strongly typed views,but can we automate this process so that I don''t have to manually go through the above steps for each and every modal and rather we can have some custom template for generating the controller and views for all the modals at one go?


Mayank Singh

推荐答案

尝试使用动态数据实体框架。



您可以使用脚手架生成实体和屏幕。
try using Dynamic Data Entities framework.

You can generate Entities and screens are generated using scaffolding.


使用T4模板

T4是一个通用的模板引擎,你可以用来g加入C#代码,Visual Basic代码,XML,HTML或任何类型的文本。使用T4的第一步是创建一个模板文件,它是文字文本,代码和处理指令的混合。 T4模板处理器将通过执行内部的代码和处理指令将此文件转换为所需类型的文本文件。



以下链接可帮助您开发自定义模板for entityframework using T4 template

http://msdn.microsoft.com/en -us / data / gg558520.aspx [ ^ ]



希望这有帮助
Use T4 Template
T4 is a general-purpose templating engine you can use to generate C# code, Visual Basic code, XML, HTML, or text of any kind. The first step in using T4 is to create a template file, which is a mix of literal text, code, and processing directives. The T4 template processor will transform this file into a text file of the desired type by executing the code and processing directives inside.

The below link helps you to develop custom template for entityframework using T4 template
http://msdn.microsoft.com/en-us/data/gg558520.aspx[^]

Hope this helps


这篇关于在ASP.net MVC中首先使用实体​​框架数据库一次性支持所有模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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