A relationship is in the Deleted state

前端 未结 3 487
臣服心动
臣服心动 2020-12-28 13:46

When I am trying to clear a collection (calling .Clear) I get the following exception:

An error occurred while saving entities that do no

3条回答
  •  醉酒成梦
    2020-12-28 14:28

    There is one trick. You can delete entities without using special DbSet:

    (this.dataContext as IObjectContextAdapter).ObjectContext.DeleteObject(entity);
    

    Execute this for each item in Availability collection before clearing it. You don't need 'identifying relationships' for this way.

提交回复
热议问题