How map objects to a view with EF 4 code first?

筅森魡賤 提交于 2019-12-28 06:18:16

问题


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

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


回答1:


Yes! I found the answer:

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.

http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/f154595c-717e-4703-a81d-ee63633a481e



来源:https://stackoverflow.com/questions/3595786/how-map-objects-to-a-view-with-ef-4-code-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!