The primary reason for making multiple versions of your data model in the first place is to handle migrations (upgrading the database) more elegantly than just deleting the existing database and creating a new one with the changes.
So if you have previous shipped versions of your app that use the previous data models AND you want the capability of upgrading the database elegantly, then just leave the previous models intact.
If the only reason you created multiple versions of your data model is to keep your data intact during initial development and no one else out there has your app with the previous data models, then delete away. It doesn't matter.
To migrate your data model automatically and elegantly use the following code in your app delegate:
// Returns the persistent store coordinator for the application.
// If the coordinator doesn't already exist, it is created and the application's store added to it.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"database.sqlite"]; //change to the name of your database
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
//[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]; --delete old model if necessary
//abort(); --Abort App if necessary
}
return _persistentStoreCoordinator;
}