Expecting too much from CoreData automatic model migration
If you use Core Data in your Cocoa application, you will have discovered Xcode 3’s mapping model to go from one model version to another. This works very nicely on your local development Mac, but not so when deploying the code to others who do not upgrade to a new version 100 times a day.
The problem is that the automatic migration of the persistent store coordinator using the NSMigratePersistentStoresAutomaticallyOption option is not as clever as expected: it only migrates using exact matches of mapping models. It does not use multiple mappings to go from very old data models to the current one. This will bite you eventually.
Reading the documentation:
NSMigratePersistentStoresAutomaticallyOption
Key to automatically attempt to migrate versioned stores.The corresponding value is an NSNumber object. If the boolValue of the number is YES and if the version hash information for the added store is determined to be incompatible with the model for the coordinator, Core Data will attempt to locate the source and mapping models in the application bundles, and perform a migration.
one can easily get the impression that it does this by talking about “mapping models”.
Also after some googling I did not find any hint about this, neither a solution.
The naive solution though works fine by just manually doing several migration steps until the current data model is reached. This is quite a lot of code, making me wonder I misunderstand anything here? This must be a problem everybody encounters eventually in Core Data apps.






