I have a difficult problem that I cannot find the answer to. My data model is structured as follows:
Version 1:
the project has many places
location has many projects
But by mistake, the reverse between them was never set.
Version 2:
Same as above, but now inverted.
An example of my problem might be the following:
In version 1, I have two projects that have the same location. When I launch version 2 and my mapping model is being processed, the original project, in order to own the location, loses its connection with this location, and now the location is displayed only as part of one of the projects, and not both of them.
I understand that this problem is probably caused by the fact that I do not establish feedback between projects and locations, but is there anything I can do to keep the data stored in two versions of the application / data model?
Edit: I tried the proposed mapping model, and I tried to manually create the mapping model. I am currently using the NSMigratePersistentStoresAutomaticallyOption key when I created my NSPersistentStoreCoordinator .
In addition, to be clear, I have two versions of my data model, and the migration is successful, the only problem is that the relationship is not saved as intended.
Edit 2: I realized that I need subclasses of NSEntityMigrationPolicy. I do not want to do full user migration, I would prefer to keep the rest of my automatic migration, if possible. Does anyone know of any good tutorials or examples on a subclass of NSEntityMigrationPolicy that will be relevant to my purpose? I couldn’t find much, and as far as I can tell, there are very few links in the Yabloko documents.
Edit 3: I have not been able to understand for my whole life how to set up feedback using NSEntityMigrationPolicy. My problem is a little different now than I described earlier. Does anyone know any convincing example of how to do this?