而不是说话让我谈谈代码:
Dim Contact = Context.Contacts.Include("Phones")
Dim phone = Contact.Phones(0)
Contact.Remove(phone)
如何刷新上下文,取消删除最后一个关系?
我试过了:
Context.Refresh(RefreshMode.StoreWins, phone) 'Doesn't recover the relation
Context.Refresh(RefreshMode.StoreWins, _
ObjectStateManager.GetObjectStateEntries(EntityState.Deleted))
最后一个抛出InvalidOperationException: 要刷新的对象集合中索引0处的元素具有null EntityKey属性值,或者未附加到此ObjectStateManager。
重要 表格结构:
联系:FirstName,LastName
电话:号码,注意
ContactPhone (多对多):ContactId(nav),PhoneId(nav)
答案 0 :(得分:4)
由于我认为这是一个错误,我向微软报告请投票并分享您的想法:http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=513174