Let's say we have a many-to-many relationship between Person and Pet entities (with no payload). When adding an existing Pet entity to a Person and saving the Person entity:
aPerson.Pets.Add(aPet);
EM.Instance.SaveChangesAsync(new [] {aPerson}); //we're using singleton pattern
This causes a duplicate (same data, different ID) aPet entity to be saved to the DB.
However, if I do this:
aPerson.Pets.Add(aPet);
EM.Instance.SaveChangesAsync();
No duplicate entry is saved to the DB. Due to the nature of our application, I really prefer saving only the aPerson entity and not the Pet entities. Any way to do this?
Edited by CJBriers - 03-Aug-2011 at 6:48am