ADO.Net EF4 Inheritance Problem. Create Child object from Base object
I have a simple EF4 Entity model in which i have a base Entity User and a child entity Tutor. The application demands that any开发者_开发百科 new entry is by default of type User(base class) which later can be upgraded to a Tutor.
So basically i wish to convert a pre existing User object into a Tutor object. I think i can do it by creating a new Tutor object with data from existing User, add extra fields, delete the old user object and try inserting the new Tutor object with same Id.
Is there any elegant way to achieve this.
The only way to create a Tutor
for an existing User
is to use a stored procedure; not a stored procedure that is wired up to the Tutor entity through mappings, but a separate one that can be called explicitly from the code.
Ideally it would be a SP that takes a UserId as a parameter, inserts a new row into the table using that UserId, and then returns a complete Tutor object so that it can be used immidiately.
精彩评论