Ans : When you initialise a Core Data stack, one of the steps involved is adding a store to the persistent store coordinator. When you encounter this step, Core Data does a few things prior to adding the store to the coordinator. First, Core Data analyzes the store’s model version. Next, it compares this version to the coordinator’s configured data model. If the store’s model version and the coordinator’s model version don’t match, Core Data will perform a migration, when enabled.
Note: If migrations aren’t enabled, and the store is incompatible with the model, Core Data will simply not attach the store to the coordinator and specify an error with an appropriate reason code.
Migrations happen in three steps:
Note: If migrations aren’t enabled, and the store is incompatible with the model, Core Data will simply not attach the store to the coordinator and specify an error with an appropriate reason code.
Migrations happen in three steps:
- Core Data copies over all the objects from one data store to the next.
- Core Data connects and relates all the objects according to the relationship mapping.
- Enforce any data validations in the destination model. Core Data disables destination model validations during the data copy.
Database Migration :
Lightweight Migration
Manual Migration
Custom Manual Migration
Fully Manual Migration
Setting for Lightweight Migration:
NSMigratePersistentStoresAutomaticallyOption: true
NSInferMappingModelAutomaticallyOption: true
Coredata Migration Tutorial : RayWanderLich
No comments:
Post a Comment
Thanks