1

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

David Ravetti
  • 2,030
  • 1
  • 17
  • 22
user320587
  • 1,347
  • 7
  • 29
  • 57
  • A great answer to an equivalent question has been posted here: http://stackoverflow.com/questions/11174773/migrating-a-many-to-many-relationship-to-a-join-table-in-core-data – mikejohnstn Jul 04 '12 at 02:45

1 Answers1

0

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.

user320587
  • 1,347
  • 7
  • 29
  • 57
  • This mostly makes sense, but are you able to provide more detail for what exactly you did? For example, pasting the Value Expressions along with the names for the two entity mappings you created. – mikejohnstn Jun 29 '12 at 05:46