Monday, June 11, 2012

Unable to determine the principal end of the '' relationship. Multiple added entities may have the same primary key.

Change the Id reference to object reference.


Example:
var player = db.PLAYERS.FirstOrDefault(p=>p.PlayerId = 13);
var newPlayer = new DRILL_PLAYERS();

newPlayer.PlayerId = player.PlayerId;           <== remove
newPlayer.PLAYER = player;                         <== use that 

db.DRILL_PLAYERS.AddObject(newPlayer);
db.SaveChanges();

1 comment:

  1. Thank you so much!
    This short and to the point example solved a problem on which I had been stuck for several hours. :)

    ReplyDelete