i\'ve read all possible blogs and SO post on the subject - but still not sure what\'s going on. I\'ve also read this but still no luck - their guide to Default migration kin
With the help i got from this question i got to solve your issue.
I have put together a demo app based on the default master/detail template with core data. When run it first time, make sure you have the "TestData" model selected in "TestData.xcdatamodeld". Add some rows, then move to "TestData 2.xcdatamodel" and the migration will make the proper changes.
The demo app can be downloaded from here
If you didn't find answer i can suggest small trick. First, idk why this happens but source model, destination model and mapping model have different values of versionHashes for same entities.
i programmaticaly corrected them and migration happens.
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"Model" withExtension:@"cdm"];
NSMappingModel *mappingModel = [[NSMappingModel alloc] initWithContentsOfURL:fileURL];
NSArray *newEntityMappings = [NSArray arrayWithArray:mappingModel.entityMappings];
for (NSEntityMapping *entityMapping in newEntityMappings) {
[entityMapping setSourceEntityVersionHash:[sourceModel.entityVersionHashesByName valueForKey:entityMapping.sourceEntityName]];
[entityMapping setDestinationEntityVersionHash:[destinationModel.entityVersionHashesByName valueForKey:entityMapping.destinationEntityName]];
}
mappingModel.entityMappings = newEntityMappings;
BOOL ok = [migrationManager migrateStoreFromURL:sourceStoreURL
type:sourceStoreType
options:nil
withMappingModel:mappingModel
toDestinationURL:destinationStoreURL
destinationType:destinationStoreType
destinationOptions:nil
error:&error];