Hi.
I'm trying to upgrade my current application to use an abstract parent entity, with specialized sub entities.
I've created a custom NSEntityMigrationPolicy, and in the mapping model I've set the Custom Policy to the name of my class.
I'm initializing my persistent store like this, which should be fairly standard :
NSError *error=nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
nil];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
NSLog(@"Error adding persistent store : %@",[error description]);
NSAssert(error==nil,[error localizedDescription]);
}
When i run the app i get the following error :
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: 'The operation couldn’t be
completed. (Cocoa error 134140.)'
[error userInfo] contains "reason=Can't find mapping model for migration"
I've verified that version 1 of the data model will open, and if i set NSInferMappingModelAutomaticallyOption i get a migration, although my entities are not migrated correctly (as expected).
I've verified that the mapping model (cdm) is in the application bundle, but somehow it refuses to find it.
I've also set breakpoints and NSLog() statements in the custom migration policy, and none of it runs, with or without NSInferMappingModelAutomaticallyOption
Any hints as to why it seems unable to find the mapping model ?