Using Mapping Models to migrate between Core Data Object Models
Posted
by westsider
on Stack Overflow
See other posts from Stack Overflow
or by westsider
Published on 2010-05-22T00:47:40Z
Indexed on
2010/05/22
0:50 UTC
Read the original article
Hit count: 506
I have a fairly simply scheme. Essentially, Run <--> Data (where a Run holds a data, e.g., Temperature, sampled from some sort of sensor).
Now, it seems that sensors can have more than one measurement (e.g., Temperature and Humidity). So, a single Run could have multiple data samples.
Hence, Run <-->> Sample and Sample <--> Data. (And for simplicity I am leaving Run <--> Data in place, for now.)
If I create a new mapping model, then things generally work - except that no new Samples are created, no relationships are established between Runs and Samples nor between Samples and Datas.
I am trying to get mapping model to migrate my model but even the slightest change to the generated mapping model results in Cocoa error 134110.
For example, if I take the "Sample" mapping (which has no Source) and set its Source to 'Run' (so that I can set Sample's inverse relationship 'run' appropriately) then the mapping changes its name to "RunToSample". There are two relationships handled in this mapping: data and run. The data property gets set automatically to
FUNCTION($manager, "destinationInstancesForEntityMappingNamed:sourceInstances:" , "DataToData", $source.dataSet)
Following this example, I set the run property to
FUNCTION($manager, "destinationInstancesForEntityMappingNamed:sourceInstances:" , "RunToRun", $source)
Similarly, I set the 'sample' property mapping in RunToRun to
FUNCTION($manager, "destinationInstancesForEntityMappingNamed:sourceInstances:" , "RunToSample", $source)
and the 'sample' property in DataToData to
FUNCTION($manager, "destinationInstancesForEntityMappingNamed:sourceInstances:" , "RunToSample", $source.run)
So, what, I wonder, is going wrong? I have tried various permutations, such as leaving the 'inverse' relationships unspecified. But I continue to get the same error (134110) regardless.
I imagine that this is a lot easier than it seems and that I am missing some fundamental but minor piece. I have also tried subclassing NSEntityMigrationPolicy and overriding -createDestinationInstancesForSourceInstance: but these efforts have met with much the same results.
Thanks in advance for any pointers or (relevant :-) advice.
© Stack Overflow or respective owner