How to map a table column to two entity properties?

三世轮回 提交于 2021-01-27 05:35:58

问题


Following this case, i'm trying to map a table column IsActive to two different entity property. is there any way to do this?


回答1:


It is not possible. Each column must be mapped only once because otherwise it would lead to inconsistencies. For example if you would set different value to each property which one should be saved? Also having two properties exposing same field doesn't make sense.




回答2:


You can't have two properties in the same Entity mapped to the same column.

But there are techniques called "Table Splitting" and "Entity Splitting" http://www.deliveron.com/blog/post/table-splitting-in-code-first-entity-framework.aspx and http://www.deliveron.com/blog/post/Entity-Splitting-in-Code-First-Entity-Framework.aspx

So you can have two different Entities mapped to the same table.



来源:https://stackoverflow.com/questions/8678972/how-to-map-a-table-column-to-two-entity-properties

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