mapping-model

how to make an iPhone app tolerant of a CoreData schema change

旧时模样 提交于 2019-12-04 13:48:18
问题 I have an app that uses the CoreData APIs extensively. I'm developing an updated version that adds a few fields to an entity. My app crashes upon load (unless if I blow away the private storage and start again) because of the schema changes. The problem is when customers upgrade to the new version, I wouldn't mind running an upgrade procedure on their data the first time the app loads, but I can't even get it to load because CoreData doesn't like that the schema changes. Is there any way to

Core data migration failing with “Can't find model for source store” but managedObjectModel for source is present

戏子无情 提交于 2019-12-03 16:48:03
问题 I have a cocoa application using core-data, which is now at the 4th version of its managed object model. My managed object model contains abstract entities but so far I have managed to get migration working by creating appropriate mapping models and creating my persistent store using addPersistentStoreWithType:configuration:options:error and with the NSMigratePersistentStoresAutomaticallyOption set to YES. NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObject:[NSNumber

how to make an iPhone app tolerant of a CoreData schema change

百般思念 提交于 2019-12-03 08:51:53
I have an app that uses the CoreData APIs extensively. I'm developing an updated version that adds a few fields to an entity. My app crashes upon load (unless if I blow away the private storage and start again) because of the schema changes. The problem is when customers upgrade to the new version, I wouldn't mind running an upgrade procedure on their data the first time the app loads, but I can't even get it to load because CoreData doesn't like that the schema changes. Is there any way to sort of tell CoreData "Its ok.. don't worry about the schema change"? Because I have only added fields

Core data migration failing with “Can't find model for source store” but managedObjectModel for source is present

怎甘沉沦 提交于 2019-12-03 06:38:36
I have a cocoa application using core-data, which is now at the 4th version of its managed object model. My managed object model contains abstract entities but so far I have managed to get migration working by creating appropriate mapping models and creating my persistent store using addPersistentStoreWithType:configuration:options:error and with the NSMigratePersistentStoresAutomaticallyOption set to YES. NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption]; NSURL *url = [NSURL fileURLWithPath:

Core Data Migration: Attribute Mapping Value Expression

寵の児 提交于 2019-12-03 00:44:57
I currently have a cardType attribute on my entity, which in the old model could be "Math", "Image" or "Text". In the new model, I'll be using just "Math" and "Text" and also have a hasImage attribute, which I want to set to true if the old cardType was Image (which I want to change to "Text"). Lastly, I have a set of another entity, "card", of which a set can be associated with a deck, and in each of those, I'll also have hasImage which I want to set to true if the deck was of "Image" type before. Is this all possible using the Value Expression in the Mapping Model I've created between the

Core Data Migration - Can't find mapping model for migration

杀马特。学长 韩版系。学妹 提交于 2019-11-30 09:10:21
I followed the guide found here: http://www.timisted.net/blog/archive/core-data-migration/ but keep getting "Can't find mapping model for migration" when I start up the app with the new model. I've tried it in xcode 3 and xcode 4, multiple times, but can never get it to work. Currently my options are set to: NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption, nil]; I had YES set for the infer option before but then it was just

Multiple Pass Core Data Migration In Chunks With iOS

女生的网名这么多〃 提交于 2019-11-30 06:49:48
I'm trying to migrate an iPhone/iPad sqlite store of about 11Mb. It has around thirty different entities, all quite heavily interrelated. On a 3GS, it takes quite some time. Even a lightweight migration takes around four minutes. I guess this is because all the relationships are held in memory. Reading the Apple migration guide, it says that for large datasets, one approach is to do multiple passes using different mapping models. All well and good. However, it seems that you can't do this if the entities in one mapping model are related to those in another. In fact, a compilation error is

Core Data Inferred Migration – Automatic “lightweight” vs Manual

百般思念 提交于 2019-11-30 00:48:54
I've updated the model of an existing iPhone app in some simple ways (remove attribute, add attribute, remove index), and can use automatic lightweight migration to migrate the persistent store. Due to the typical size of the data set, the processing time is not insignificant, and warrants feedback for the user. NSMigrationManager provides a simple but useful migrationProgress value that sends KVO notifications as the migration is performed. That forms the basis of providing feedback, however attempting to use an inferred model ( [NSMappingModel inferredMappingModelForSourceModel

Core Data Migration Across Multiple Version Upgrades

亡梦爱人 提交于 2019-11-29 20:59:19
I have an iPhone app that uses Core Data. I did an update and used Lightweight Migration to go from V1 to V2 of my MOM (Managed Object Model). This worked perfectly. What happens when I want to go to V3 (and beyond) of my MOM? If I decide to continue with Lightweight Migration, will it automatically deal with migrating from V1 to V3 and V2 to V3 of my MOM, or do I need to do something extra? If I decide to use a mapping model, what happens? How do I deal with upgrading both V1 and V2 MOM's to V3? Do I need to create a mapping model for both V1 to V3 and V2 to V3? This question goes further ...

iPhone Core Data Lightweight Migration: Can't merge models

旧巷老猫 提交于 2019-11-29 08:20:43
I just started with iPhone core data and I ran into a problem in lightweight migration. I added two new fields to my old model Regenerated the model class files Made the new model version as current version Added the following code in AppDelegate in the template generated NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL