I have a simple entity data model where I have two entities and a 1-* relation between them. For simplification purposes let’s say Person and Book. (i.e. people have 0 or more books and books must have an owner)
The system works fine and it has data in it.
Now I need to create other entities inherited from Person (i.e. Student, Teacher)
When I create them and update my software accordingly, everything works fine with this new model.
Now I need to migrate the old data (data in Person which is linked to books)
In my data I know which person’s are student and which are Teacher and I have additional information on the Students and Teachers that I’ll place in the new model.
The question is how do I migrate the data. I cannot add Students and Teachers before I delete the Person instance because that would create duplicate Id in Person. I cannot delete the Person as it creates an error. (“DELETE statement conflicted with REFERENCE constraint”)
How do I acheive this data migration.
Thanks
If you really have mapped inheritance you should not delete
Person– thePersonis eitherStudentorTeacherso you should just add correct columns (in case of TPH) or related tables (in case of TPT) and use existing data without their modification.This migration must be done in SQL.