I was referring a wonderful tutorial Swift Core Data Tutorial for migrations in core data.
The tut stated that migrations in core data go hand in hand with multiple versions of data model.
I was experimenting on light-weight migrations and got to figure out the following points:
Scenario - I had a data model and I tried to add a some new attributes to an entity and I got an error as -
iOS Version - 9.1 Swift Version - 2.2
"The model used to open the store is incompatible with the one used to create the storeā
I then tried to enable migration without creating any new version by adding the code -
let options = [ NSMigratePersistentStoresAutomaticallyOption : true, NSInferMappingModelAutomaticallyOption : true ]
try persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: URLPersistentStore, options: options)
Then I tried altering the database similarly, i.e added an attribute to an entity and hurrah !!, it didn't result in a crash. Even I tried to access the particular entity as well as attribute but did it successfully.
What happened is migration without having multiple versions.
Question - So Is migration possible without having multiple versions of data model?
Link to sample code - https://www.dropbox.com/s/mnb2dzxn56ghuet/CoreDataSwift-NSFetchedResultsController-master-2.zip?dl=0