In v1 of my model I have a one to many relationship between a presentation
and slides
:
presentation---->>slides
In v2 I fix this foolishness by adding an inverse one to one:
presentation<--->>slides
In both models a slide
belongs to 1 and only 1 presentation
(although this is not codified within the models).
How do I specify the value expression in the mapping model to create the slide-->presentation
relationship without creating an NSEntityMigrationPolicy
subclass?
As far as I can tell it is not possible to do this with a Value Expression in the mapping. The solution is to create a NSEntityMigrationPolicy
subclass for the mapping.
In the NSEntityMigrationPolicy
subclass override createRelationshipsForDestinationInstance:entityMapping:manager:error:
. In this method fetch the related object with a standard NSFetchRequest
executed in the managers destinationContext
. Be sure to call super
to ensure that any other relationships are also migrated.