问题
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