如何映射对象与EF 4 code第一个看法? [英] How map objects to a view with EF 4 code first?

查看:103
本文介绍了如何映射对象与EF 4 code第一个看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么能一个实体映射到一个数据库视图与EF 4 code第一?

How can you map an entity to a database view with EF 4 code first?

有没有办法从EntityConfiguration类派生来做到这一点?

Is there a way to do this by deriving from the EntityConfiguration classes?

推荐答案

是的! 我找到了答案:

Yes! I found the answer:

您当然可以使用code先   映射到一个视图,只是告诉$ C C首先$   这是一个表,它将使用   反对观点,即相同的SQL   会为一个表。显然,如果您   看法是不写那么储蓄   打算如果你尝试更新失败   这是根据在实体值   在视图,但我们只是委托   到数据库中,所以如果你不更新   这些实体,那么你将不会有任何   的问题。

You can certainly use Code First to map to a view, just tell Code First that it's a table and it will use the same SQL against the view that it would for a table. Obviously if your view isn't writeable then saving is going to fail if you try and update values in the entities that are based on the view, but we will just delegate to the database so if you don't update these entities then you won't have any issues.

<一个href="http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/f154595c-717e-4703-a81d-ee63633a481e">http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/f154595c-717e-4703-a81d-ee63633a481e

这篇关于如何映射对象与EF 4 code第一个看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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