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();
Thank you so much!
ReplyDeleteThis short and to the point example solved a problem on which I had been stuck for several hours. :)