开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜