Questions tagged [mapping-model]

A mapping model is a Core Data construct that helps define how one version of a object model is migrated to another version the object model.

A mapping model is a collection of objects that specifies the transformations that are required to migrate part of a store from one version of your model to another (for example, that one entity is renamed, an attribute is added to another, and a third split into two). You typically create a mapping model in Xcode. Much as the managed object model editor allows you to graphically create the model, the mapping model editor allows you to customize the mappings between the source and destination entities and properties.

from Core Data Model Versioning and Data Migration Programming Guide

67 questions
5
votes
1 answer

Migrating through several versions in core data

I have Core Data application and I have been migrating (upgrading) the core data model. Each time I create a new version I create a mapping model for each version. Right now I have 16 versions and I have mapping models that go like…
the Reverend
  • 12,305
  • 10
  • 66
  • 121
5
votes
1 answer

How to split an entity in Core Data migration mapping

It seems like this should be straight forward but I have not been able to find a good example of it. I have a simple Core Data entity that I want to split into two separate entities. Apple's documentation mentions it at a high level (Mapping…
Greg Martin
  • 5,074
  • 3
  • 34
  • 35
4
votes
1 answer

How to map parent column in EF 4.1 code first

In my project I have following DomainModel. public class Login { public Guid Id { get; set; } public Login CreatedBy {get; set; } } I am using fluent configuration as below: modelBuilder.Entity() .HasKey(x => x.Id) …
learner
  • 129
  • 9
4
votes
3 answers

Manual Core Data schema migration without "document changed" warning?

The data model for my Core Data document-based app (10.5 only) is in a framework, so automatic schema upgrades using a Core Data mapping model don't appear to work. It appears that the Core Data machinery doesn't find the appropriate data models or…
Barry Wark
  • 107,306
  • 24
  • 181
  • 206
4
votes
1 answer

Which kind of changes can't I do with lightweight migration in Core Data?

I recently tried a lot of different stuff with lightweight migration. These all work: 1) Rename attributes (with renaming identifier specified) 2) Add attributes 3) Add new entity + new attribute + inverse relationship to an already existing…
dontWatchMyProfile
  • 45,440
  • 50
  • 177
  • 260
4
votes
2 answers

Core Data migration failing with error: Failed to save new store after first pass of migration

In the past I had already implemented successfully automatic migration from version 1 of my data model to version 2. Now, using SDK 3.1.3, migrating from version 2 to version 3 fails with the following error: Unresolved error Error…
Massimo Cafaro
  • 25,429
  • 15
  • 79
  • 93
4
votes
2 answers

Handling Core Data Model Changes

I know that if you change the Core Data model and you have run the app before on the old model that you will get Persistent Store error. How would you handle changes to the Core Data model so you do not get this error? Is there a way to upgrade an…
Joshua
  • 15,200
  • 21
  • 100
  • 172
3
votes
1 answer

Core Data migrating one-to-many relationship

Initially the model is like this, where the department has a set of workers: Department <--->> Job <--->> Worker and it needs to be changed so the Worker relationships are moved to being relative to the Jobs, I think I need…
Pierre Houston
  • 1,631
  • 20
  • 33
3
votes
1 answer

Backing out a Core Data migration?

I have an app with a very large Core Data database. I have versioned it many times over the past year. The last time I versioned the database I made one simple change to an entity: I added a new optional attribute. For some reason it would not…
toofah
  • 4,455
  • 4
  • 31
  • 42
3
votes
1 answer

Preserving core data after app update

I am using core data to store favorites chosen by the user. I would like to know that if I send an app update, how can I keep the data of the favorites preserved after the app is updated by the user? I have read that you could use versioning, but…
Peter
  • 181
  • 2
  • 10
3
votes
1 answer

iPhone Core Data Lightweight Migration: Can't merge models

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…
vikmalhotra
  • 9,981
  • 20
  • 97
  • 137
3
votes
1 answer

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

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…
Mike S
  • 4,092
  • 5
  • 35
  • 68
3
votes
2 answers

Core Data migration of to-one relationship to to-many relationship

I have a deployed app that samples measurements from sensors (e.g., Temp °C, Pressure kPa). The user can create Experiments and collect samples. Each sample is stored as a Run, such that there is a one-to-many relationship from Experiment to Run. In…
3
votes
1 answer

Core Data Migration - "Can't add source store" error

In my iPhone app I'm using Core Data and I've made changes to my data model that cannot be automatically migrated over (i.e. added new relationships). I added the data model version (Design -> Data Model -> Add Model Version) and applied my new data…
Tofrizer
  • 379
  • 4
  • 15
3
votes
1 answer

Core Data Mapping Model version hashes not matching to source model version hashes

With Core Data Migration Debug enabled, when performing a migration I see three entities (2, 3, 4) with changed hashes, as expected. Entity 1 doesn't change and is for illustration. Store metadata (source model): Entity1 = <67852e01 ...>; Entity2 =…
Victor Bogdan
  • 2,022
  • 24
  • 33