Another Core Data post. Last one for a while I expect.

It seems that when you create a mapping model for core data migrations using XCode (3 or 4) it will not create mapping models for abstract entities you could try here. If you do not create this manually within your mapping model any data contained therein will be lost. In my case I needed to tie the image data back to the entity it belonged to. I could create several entities each with the requisite attributes but it made more sense to create one abstract image entity and have the others inherit from it. This enabled me to have a recipeimage and stepimage that could have relationships back to their parent without having to create lots of attributes. RecipeImage has Image as a parent and has a defined relationship with Recipe etc. The downside is that after migration if you do not create the Image mapping manually all you images vanish from the database.
I cannot fathom a good reason for this mapping not being created automatically, under what circumstances would you not want the data contained in an abstract entity migrated when you update the schema? At least it was easy to fix.

This entry was posted in Programming and tagged , , . Bookmark the permalink.

Leave a Reply