I have a simple 2 object inheritance defined in an EF model, Person <- User.
Person is the base entity/class, it is not abstract, and it contains fields like firstname, lastname, email.
User is the derived entity/class, and contains fields like username, lastlogin, islockedout.
The database uses a table-per-type schema, so there is 1 table for Person, and another table for User. Both use the same primary key field, PersonID. PersonID is an IDENTITY column, but in the EDM, StoreGeneratedPattern for PersonID is set to None.
Because this is a table-per-type inheritance schama, there can be a Person row/object that doesn't have a corresponding User row/object. This is so that the system can contain data about people who are not users. However, a Person may eventually become a User, and this is where I'm having problems.
I have a test case for this scenario, where the system finds a Person that it wants to turn into a User. I've tried setting the PersonID field on a new User object, adding it to the ObjectContext, and saving changes. What happens is the database creates a new Person row along with the new User row, ignoring the value I set for PersonID.
How can I get around this? Do I have to create sprocs to handle the EDM crud operations?