ASP.NET MVC 3:自动生成视图,同时加入控制器(无实体框架) [英] ASP.NET MVC 3: Automatically generating view while adding controller (without Entity Framework)

查看:121
本文介绍了ASP.NET MVC 3:自动生成视图,同时加入控制器(无实体框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学MVC。我想自动生成所需的视图code作为,当我添加一个控制器。这是可能的,如果我选择选项与读取器/写操作和视图,使用实体框架。但是我没有使用实体框架。我怎样才能做到不使用实体框架的类似的行为?以及为什么它不能自动生成,当我不使用实体框架的看法?

此外,有没有不使用实体框架(提供code下载)?

什么好MVC3教程

参考


  1. <一个href=\"http://stackoverflow.com/questions/431988/how-do-i-configure-asp-net-mvc-to-scaffold-using-ado-net-dataservice\">How怎样设定ASP.net MVC使用ADO.net DataService的脚手架?


  2. Levergaing T4Scaffolding为WCF的Web API


  3. ASP.NET MVC 3和NHibernate脚手架


  4. 与MvcScaffolding包的脚手架ASP.NET MVC 3项目


  5. <一个href=\"http://stackoverflow.com/questions/6693334/once-again-linq-to-sql-or-entity-framework-for-new-mvc-3-project\">Once再次的LINQ to SQL或实体框架新的MVC 3项目


  6. 脚手架MVC WCF服务的


  7. <一个href=\"http://stackoverflow.com/questions/5326515/create-a-dropdown-list-for-mvc3-using-entity-framework-edmx-model-razor-vie\">Create一个下拉列表,使用实体框架(型号的.edmx)及MVC3;剃刀观点与放大器;&安培;插入数据库记录到多个表



解决方案

您可能会发现的部分的您正在寻找的史蒂夫·桑德森的mvcScaffolding包

的NuGet

 安装封装MvcScaffolding

安装(它可能会安装一些EF要求),你可以为脚手架模型的基本CRUD意见如下假设模型类型后 MySweetModel

 脚手架浏览MySweetModel

请注意此命令将的的创建控制器类,而应创造条件,以下意见/查看/ MySweetModel


  • _CreateOrEdit.cshtml

  • Create.cshtml

  • Delete.cshtml

  • Details.cshtml

  • Edit.cshtml

  • Index.cshtml

看起来你可能能够覆盖默认的T4模板,但我从来没有用过MvcScaffolding EF的范围之内。它也有可能有人已经这样做了你的持久层例如NHibernate的或任何你正在使用。我想实现自己的模板之前,查了一下。

I am trying to learn MVC. I want to automatically generate the required view code as and when I add a controller. This is possible if I select the option "Controller with read/write actions and views, using Entity Framework" . However I am not using Entity Framework. How can I achieve the similar behavior without using Entity Framework? And why it is unable to automatically generate the view when I don’t use Entity Framework?

Also, is there any good MVC3 tutorial that does not use Entity Framework (with code download available) ?

Reference

  1. How do I configure ASP.net MVC to Scaffold using ADO.net dataservice?

  2. Levergaing T4Scaffolding for WCF Web API

  3. ASP.NET MVC 3 and NHibernate Scaffolding

  4. Scaffold your ASP.NET MVC 3 project with the MvcScaffolding package

  5. Once again LINQ to SQL or Entity Framework for new MVC 3 project

  6. MVC Scaffolding for WCF Services

  7. Create a Dropdown List for MVC3 using Entity Framework (.edmx Model) & Razor Views && Insert A Database Record to Multiple Tables

解决方案

You might find some of what you're looking for in Steve Sanderson's MvcScaffolding package

Nuget

Install-Package MvcScaffolding

After installing (it will probably install some EF requirements) you could scaffold basic CRUD views for your model as follows assuming a model type MySweetModel

Scaffold Views MySweetModel

Please note this command will not create the controller class, but should create the following views under /Views/MySweetModel

  • _CreateOrEdit.cshtml
  • Create.cshtml
  • Delete.cshtml
  • Details.cshtml
  • Edit.cshtml
  • Index.cshtml

It looks like you might be able to override the default T4 templates, but I've never used MvcScaffolding outside the scope of EF. It's also possible someone has already done this for your persistence layer e.g. NHibernate or whatever you're using. I'd search a bit before implementing your own templates.

这篇关于ASP.NET MVC 3:自动生成视图,同时加入控制器(无实体框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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