I have two classes:
public class Foo { public int FooId {get;set;} public virtual ICollection Bars {get;set;} } public class Bar { pu
Try
var bar = new Bar(); context.Bars.Add(bar); bar.Foo == foo; context.SaveChanges();
It seems like the entity key isn't being set uniquely when assignment occurs before the entity is added to the context.