I have a CoreData model that looks like this:
- Abstract Entity
- Entity 1
- Entity 2
- Entity 3
“Abstract Entity” is the top entity in the hierarchy. “Entity 1” and “Entity 2” are peer sub entities of “Abstract Entity”. “Entity 3” is a sub entity of “Entity 2”.
The app is live in the App Store, so any amendments to the model must retain all existing data. Unfortunately, I now need to re-arrange the model hierarchy to look like this:
- Abstract Entity
- Entity 2
- Entity 3
- Entity 1
- Entity 3
- Entity 2
Is there any way of achieving this that doesn’t involve creating a new “Entity 4” entity and writing a function that will convert all “Entity 1” data into “Entity 4” format? I’d rather not end up with a crufty hierarchy like this:
- Abstract Entity
- Entity 1
- Entity 2
- Entity 3
- Entity 4
- Entity 3
The only way I’ve come up with of avoiding the above is to copy all of the properties I need from entities 2 and 3 into 1 and just ignore the hierarchy problem entirely, which is a bad solution.
I’d suggest you read up on and create a custom mapping model.