Automatic migration with abstract entities
I have a model that has an abstract entity with two entities that inherit from this abstract entity.
When I try doing automatic migration I get an error about there being no mapping model so I created a mapping model and then ge开发者_开发技巧t errors about multiple validation errors. Looking closely at the mapping model that has been generated neither of the entities have any attributes from their parent included in the mapping model, one of which is not optional and seems to be generating the error during migration.Is it possible to use automatic migration when abstract entities have been used ?
If not then I am busy creating a custom migration class using the following simple statements to migrate each attribute.
[newObject setValue:[sInstance valueForKey:@"name"] forKey:@"name"];
How do I migrate relationships ? Can I use the same approach for relationships shown below ?
[newObject setValue:[sInstance valueForKey:@"parent"] forKey:@"parent"]; [newObject setValue:[sInstance valueForKey:@"children"] forKey:@"children"];
Thanks.
OK I found my problem - DO NOT make any small changes to your original data model because things will fail !!!
I have mistakenly made a change to the original data model, once I have figured out what this was and reset it things started working.
To overcome the abstract entity problem I had to create a CustomMigrationClass which copies each attribute and relationship across. All works nicely now.
精彩评论