Core Data Force Custom Mapping Model/Policy instead of Lightweight Migration
Asked Answered
V

1

8

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?

Voguish answered 9/11, 2010 at 18:54 Comment(0)
T
1

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

Trucker answered 12/1, 2011 at 22:7 Comment(1)
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.