1
votes

I am trying to use the Entity Mapping Model to migrate my existing many-to-many relationships in my application. I have the following relationships

Teams <<----->> Players

A Team entity can have multiple players, and a Player can be part of several teams. Now, I am trying to split this relationships to one to many by introducing a new entity with the following properties

TeamToPlayer
  Team *team
  Player *player

So the new relationship will look like

Team <--->> TeamToPlayer
Player <-->> TeamToPlayer

I am trying to figure what kind of entity mapping should be I be using to transform my core data model. Is it possible to do the above using the Mapping model or do i need to write code by inheriting NSMigrationPolicy class. Any thoughts would be very helpful.

Thanks, Javid

1
A great answer to an equivalent question has been posted here: stackoverflow.com/questions/11174773/…mikejohnstn

1 Answers

0
votes

After trying to understand the migration process and entity mapping models for couple of days, I finally managed to find a solution. I was surprised to find how simple it was.

I created two entity mapping with Source from Player & Team to TeamToPlayer and mapped the relationships from the source entity to the destination entity relationship. And updated the relationship mapping names in the PlayerToPlayer and TeamToTeam relationship mapping to use the new entity mappings. Everything just worked.