I found the documentation is very limited and my solution to the problem is nowhere.
I need to add a new entity (with relation to an existing one). Also add and rename some attributes of an existing object.
Light weight example:
The old model has one object Itemwith one attribute name.
In the new model, I want to Itemhave one new attribute dateAddedand rename nameto title. In this case, if it dateAddedis optional or given a default value, I could use lightweight migration. Correct me if I am wrong.
But I also want to add a new object Listwith an attribute title. And add to many relationships. The list may be empty or have many elements. An item must refer to only one list.
So, I am confused by what I need to do and what order.
Enable migration with the weight transfer function disabled ( NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption, nil];).
Create a new version of the model. There I make the changes I want.
Create a new mapping model. The source is the old model, the goal is the new model. In ItemToItemI installed titlein $source.name.
, Xcode , , . , List - . NSEntityMigrationPolicy . ?