antalkerekes
antalkerekes

Reputation: 2128

CoreData migration & data mapping: creating a new entity from existing attribute

I really hope someone will be able to help me out with this. I am trying to create a data mapping model (for an iOs app) in Xcode for the first time.

This should be a very simple migration (although not covered by lightweight migration); here is what I originally had and what the new database looks like: before/after image of database model

What changed:

So basically I only need to copy data from one attribute, which now resides in a new entity.

I would be very grateful if someone could point me in the right direction, or just recommend a good resource to study from and get started.

Upvotes: 4

Views: 2265

Answers (2)

antalkerekes
antalkerekes

Reputation: 2128

I have sold this problem using a great description found here.

Update: (Fixed link to what appears to be the same blog post)

Here is the working mapping model:

DB mapping model #1 DB mapping model #2

I hope it helps someone.

Upvotes: 8

TechZen
TechZen

Reputation: 64428

Creating a mapping model can get fairly involved. I would start with the Core Data Model Versioning and Data Migration Programming Guide

In this particular case you will need to create an explicit mapping model, then you will have to create an entity mappings that describes both your original entity and the new target entity you want to move the attribute to. Then create a property mapping for that particular attribute.

Upvotes: 0

Related Questions