entity framework inserting a many to many relationship across multiple contexts
I have an Events table and a PaymentTypes table which are linked by Events_PaymentTypes join table. EF allows me to add an entry into the join table by doing Event.PaymentTypes.Add(PaymentType). However, I'm getting the PaymentTypes from one contex开发者_如何学Ct and doing the add operation in another context. If I detach the PaymentType first, it creates a new record in the PaymentTypes table, which is not what I want. How can I get around this?
figured it out. I wasn't attaching it to the other context before adding it.
精彩评论