Changing Inherited Types in Entity Framework

自古美人都是妖i 提交于 2019-12-17 14:54:17

问题


I see there is a similar question asked here but I don't think it was very clear so I'm creating another : Entity Framework: Inheritance, change object type

I have an Entity Student that inherits from an Entity Person.

At some point a Person could become a Student.

Is there any way in Entity Framework 4 to handle this without a stored procedure or creating a new entity.


回答1:


No. The EF inheritance does not support this scenario. The best way to create a Student for an existing Person is to use a stored procedure.
Please note that this is not a stored procedure that is wired up to the Student entity through mappings, but a separate one that can be called explicitly from code. Ideally it would be a SP that takes a PersonID as a parameter, inserts a new row into the Student table using that PersonID, and then returns a complete Student so that it can be used immidiately.



来源:https://stackoverflow.com/questions/3823662/changing-inherited-types-in-entity-framework

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