Reputation: 4856
I have four versions of my CoreData model. I've just added the fourth with a small change, a new optional attribute in one entity. Between version 2 and 3, I've made a mistake and made a change to the existing model instead of creating a new version. I restored version 2, added the version 3 and forced a delete of the store, so the users that were updating the app were re-generating the store and not performing a migration.
This worked well, but now I'm trying to perform a lightweight migration with CoreData plus MagicalRecord, from version 3 to 4 of my store and I'm always getting a Can't find or automatically infer mapping model for migration
error. I would like not to force the delete again, but I'm stuck at what else can I do to solve the lightweight migration. I'm starting to suspect that the problem still lies between version 2 and 3, but I can't confirm that.
The code I'm using to set up my store is quite simple:
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"Store.sqlite"];
Upvotes: 0
Views: 187
Reputation: 69707
This error message usually means that you have either deleted or not included either the source or destination model in your app bundle, so core data cannot build a mapping model for you. The way to see what entities are effected is to print out the model hashes to the console and compare to see which entities have changed. From there you can determine how you need to build your mapping model. Also remember that migrations aren't sequential. You have 4 versions of your model which means you now have 4 x 3 x 2 migration combinations. Core data will only do one, from the version your source store is at, and the latest version. So you also need to test migrations from v1 to v4, v2 to v4 etc to cover all your bases.
Upvotes: 1