问题
I'm trying to perform a core data migration and everything is working fine, except that the migration itself takes over 10 seconds. I'm using an xcmappingmodel to map between my two model versions which works fine, except for the length of time it takes.
In the code below, there's a 10 second (or longer!) pause between the "Beginning migration" and "Finished migration" logs. Has anyone encountered such a slow migration before?
I know that all of the data is replicated and transferred to the new store during the migration, but I'm not dealing with a huge dataset, maybe 20 entities with 3,000 records, so I can't imagine it'd take that long.
I'd really appreciate any help - thanks!
Michael
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSLog(@"Beginning migration");
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
NSLog(@"Auto migration failed, error %@, %@", error, error.userInfo);
abort();
}
NSLog(@"Finished migration");
来源:https://stackoverflow.com/questions/10803201/core-data-migration-very-slow