Core Data Lightweight Migration Woes
Core Data Lightweight Migration Woes
- Subject: Core Data Lightweight Migration Woes
- From: Brad Gibbs <email@hidden>
- Date: Thu, 19 Aug 2010 14:31:14 -0700
I'm still having problems migrating to a new version of my data model. I created a small project to test migration and everything worked smoothly -- so smoothly that trying to get it to fail wasn't easy. But, doing the same sorts of things to migrate to a new version of the data model in my main app is failing all over the place and I have no idea why.
I'm using versioning. I use Design > Data Model > Add Model Version. A new version of the data model is created. I edit the unnumbered data model and make sure it's set as the Current Model Version. To keep things simple, I've been trying to add a single string attribute to a single entity. Build & Go and I get:
Error Domain=NSCocoaErrorDomain Code=134130 UserInfo=0x2002a29a0 "Persistent store migration failed, missing source managed object model.
If I delete the attribute that I just added and Build & Go again, everything works smoothly.
All entities in the model have their own custom classes and several of those custom entities have categories, where I've been keeping the methods.
If I'm building a managedObjectModel using -modelByMergingModels, do I need to be doing something differently? My managedObjectModel method is below. I'll post the -persistentStoreCoordinator method, as well, if it would help (adding it to this email puts me over the size restriction).
Thanks.
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel) return managedObjectModel;
NSManagedObjectModel *prototypeModel;
// create object for prototype model
NSString *prototypePath = [[NSBundle mainBundle] pathForResource:@"IconConfig" ofType:@"mom"];
if (prototypePath == nil) {
prototypePath = [[NSBundle mainBundle] pathForResource:@"IconConfig" ofType:@"momd"];
}
NSLog(@"Prototype path is %@", prototypePath);
NSURL *prototypeURL = [NSURL fileURLWithPath:prototypePath];
NSLog(@"Prototype URL is %@", prototypeURL);
prototypeModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:prototypeURL];
if (!prototypeModel) {
NSLog(@"prototype model couldn't be found.");
}
// create object for media resouces model
NSString *resourcesPath = [[NSBundle mainBundle] pathForResource:@"MediaResources" ofType:@"mom"];
if (!resourcesPath) {
return nil;
}
NSURL *resourcesURL = [NSURL fileURLWithPath:resourcesPath];
NSManagedObjectModel *resourcesModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:resourcesURL];
// create merged model
managedObjectModel = [NSManagedObjectModel modelByMergingModels:[NSArray arrayWithObjects:prototypeModel, resourcesModel, nil]];
return managedObjectModel;
}
_______________________________________________
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