views:

43

answers:

2

So I created a new version of my data model, and made a previously optional field non-optional (giving it a default value). According to the documentation, this should mean my migration is eligible for lightweight, automatic migration.

I also added options that allow this when I open the store, also per the documentation:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:

                    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,

                    [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

When my app is starting, however, I get the following error: "Can't find or automatically infer mapping model for migration".

Does anyone know what the problem here could be? Any help is appreciated... thanks!

A: 

Do you also have to specify a default value for the Attribute if you make it non-optional?

Shaggy Frog
I don't mind the neg. I mind not being told why. How lame.
Shaggy Frog
Ahh, probably because I answered your question in my description: "giving it a default value".
elsurudo
Gotcha......15chars
Shaggy Frog
A: 

You've probably looked at this, but if not ... Detecting a Lightweight Core Data Migration

In terms of other debugging code, I found this helpful:

   NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"MyDataStore.sqlite"]];

NSError *error = nil;
NSDictionary *sourceMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType
                                                                URL:storeUrl
                                                                error:&error];

if (!sourceMetadata)
    {
    DLog(@"sourceMetadata is nil");
    }
else
    {
    DLog(@"sourceMetadata is %@", sourceMetadata);
    }

And finally, this is kind of a pain but in the Finder you can "Show Package Contents" for your app and then find a folder called .momd and within that is a file called 'VersionInfo.plist'. This has been helpful in identifying what you have and where you're trying to go.

And finally, you could try to create a mapping model and see if that works. I've wrestled with migration issues for weeks, hence the long list of desperate debugging attempts.

westsider