CoreData Migration Problems
CoreData Migration Problems
- Subject: CoreData Migration Problems
- From: Gordon Apple <email@hidden>
- Date: Tue, 08 Feb 2011 14:08:04 -0600
- Thread-topic: CoreData Migration Problems
I am trying to migrate an existing app CoreData database to a new version.
Theoretically, this should be what's called a simple migration. I have not
been able to get it to work. Just to see what it's trying to do, I went
ahead and let it generate a mapping model, which appears to be correct. But
somehow, it is apparently not reading the original database. The following
returns nil.
- (NSPersistentStoreCoordinator*)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil)
return persistentStoreCoordinator;
NSURL *storeUrl = [NSURL fileURLWithPath: [[[self class]
appStorageDirectory] stringByAppendingPathComponent: @"myApp.sqlite"]];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES],
NSInferMappingModelAutomaticallyOption,
nil];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel: self.managedObjectModel];
NSError *error = nil;
NSPersistentStore* store =
[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeUrl
options:options
error:&error];
if(store != nil)
return persistentStoreCoordinator; // Normal exit.
// Error handling...
return nil;
}
I've read the docs (multiple times) and two books. I am wondering if I
inadvertently changed some minor thing in the original, getting a different
hash value.
I am confused about some things going on behind-the scenes. The project
folder contains only the xcdatamodeld file (the compiled version), not the
original xcdatamodel shown in the project listing. Also, for the main
entity, somewhere along the way, the project folder has picked up a folder
labled "Model-1.moved-aside", which does not show up in the project window.
Is this something needed in the migration? I'm about at my wit's end with
this thing.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden