How do I save a child entity in EntityFramework 4?
问题 I have a 1-1 relationship between Orders and Contact. i.e. Contact.OrderId references Orders and is also a PK. So I have an existing Order and I add a new Contact to it like so... order.Contact = new Contact() { EmailAddress = "hello" }; context.Orders.Attach(order); context.SaveChanges(); A referential integrity constraint violation occurred: The property values that define the referential constraints are not consistent between principal and dependent objects in the relationship. So what am