基于数据库表脚手架的ViewModels [英] scaffolding viewmodels based on database tables

查看:103
本文介绍了基于数据库表脚手架的ViewModels的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么,将有助于我们在设计/脚手架查看模型从SQL Server数据库表,但会导致非常精简类?我知道这样的事情存在Rails的,也许有类似于ASP.NET MVC的东西吗?

Is there anything that would aid us in designing/scaffolding View models from SQL Server database tables but would result in very lean classes? I know something like that exists for Rails, maybe there's something similar in ASP.NET MVC?

我喜欢EF向导创建,但它太重了 - 太多的属性,约束,事件和一切连接到实体,所以你不能真正使用它们作为查看模型(其实你可以,但它很快就变成一个痛苦)

I like what EF wizard creates but it's too heavy - too much attributes, constraints, events and everything is attached to the entities so you can't actually use them as View models (actually you can but it quickly becomes a pain).

推荐答案

我想你可以使用POCO发电机为您EF4模型而不是默认的。这是怎么解释的链接。 <一href=\"http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx\"相对=nofollow>链接
我希望你能适应它来满足您的需要。

I think you could use a POCO generator for your EF4 model instead of the default one. This is a link explaining how. LINK I hope you can adapt it to fill your needs.

一个POCO类(普通老式CLR对象)是定义一个轻量级的类,它是(也许)你要找的是什么

A POCO Class(Plain Old CLR Objects) is by definition a lightweight class, that is (maybe) what you're looking for.

这篇关于基于数据库表脚手架的ViewModels的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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