You need to add the NSMigratePersistentStoresAutomaticallyOption
& NSInferMappingModelAutomaticallyOption
options:
Try this:
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:@{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES} error:&error]) {
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];
NSLog(@"Deleted old database %@, %@", error, [error userInfo]);
[persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:@{NSMigratePersistentStoresAutomaticallyOption:@YES} error:&error];
}
NOTE: you need to turn on model versioning first and make sure that you create a new version of your data model each time you change it.
Read the apple documentation about model migration here.