I have a old core data model with two entities:
First entity
FirstString has an attribute: string1 which is NSString
Second entity
SecondString has an attribute: string2 which is NSString
They have a one to many relationship: first entity <--->> second entity.
The new entity - "ComboEntity" - has one to one relationship with both first entity and second entity.
Now I have new core data model with new entity
ComboEntity has an attribute: fullString
Question:
How do I migrate the data and combine string 1 and string 2 into fullString?
Thanks!
CoreData model versioning has extensive support on iOS. Basically you need to create a new version of your model and create the new entity in that (possibly leaving also the old entities). Then, depending on your need, you can choose different levels of migration support from the framework, starting from "lightweight migration" that simple fills the new fields with nil, until "custom entity migration policies" that allows you to define callback functions that will do migration process of arbitrary complexity. See here.
In your case you could do the migration also manually, checking at every application start (or just once) whether the model is converted already, and if not, run a loop that fills the new entity based on the old ones.
You should use a custom mapping policy.
In your mapping model you write a value expression as shown in the screenshot. Instead of contactHashMD5 you'd have your fullString attribute instead.
Best regards,
sven.