I've got about 4 different versions of my data model now, and every one except the last one has been just a minor change using automatic lightweight migration. For this latest model, I need to do a bit of additional work during the migration, so I created a custom mapping model and a migration policy subclass with some actions in the createDestinations and createRelationships. Problem is, my mapping model/custom policy isn't being called, and it seems that Core Data is trying to perform lightweight migration instead. Is there something I need to do to keep lightweight migration around, but use my mapping model when there's one available?
Core Data Force Custom Mapping Model/Policy instead of Lightweight Migration
Asked Answered
You have to change the way your PSC is being initialized. Try setting both NSInferMappingModelAutomaticallyOption and NSMigratePersistentStoresAutomaticallyOption to YES. See http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CoreData/Articles/cdUsingPersistentStores.html
Also, you need a mapping model from each of the old versions to the new one, since the default migration process looks for a direct mapping model. Sad days. –
Prevenient
© 2022 - 2024 — McMap. All rights reserved.