Lightweight Migration

Whenever a new model is set as the current version, existing persistent stores must be migrated to use them. This is because the persistent store coordinator will try to use the latest model to open the existing store, which will fail if the store was created using a previous version of the model. The process of store migration can be handled automatically by passing the following options to a persistent store coordinator in an NSDictionary as a store is added to it:

image When NSMigratePersistentStoresAutomaticallyOption is YES and passed to a persistent store coordinator, Core Data will automatically attempt to migrate lower ...

Get Learning Core Data for iOS: A Hands-On Guide to Building Core Data Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.