Closed ghost closed 9 years ago
If anyone has the same issue, I wasn't able to resolve the issue even with the latest dev build. I ended up just detecting if an object was removed and removing all children before calling UpdateGraph. It still handles adds and updates nicely, but child deletes fail frequently.
Is that relationship's foreign key configured to cascade on delete?
Facing the same issue here... Did you find any solution to this?
Yes, you have to cascade on delete.
Here's my schema.
I've set up my graph diff like so.
var inspect = ctx.UpdateGraph(entityOrder, orderProduct => orderProduct .OwnedCollection(p => p.OrderProducts, op => op .OwnedCollection(attr => attr.OrderProductAttributes) .OwnedCollection(discount => discount.OrderProductDiscounts)) .OwnedCollection(orderDiscount => orderDiscount.Discounts) .OwnedCollection(cpi => cpi.CustomerProvidedItems) .OwnedCollection(documents => documents.Documents) ); If I attempt to remove an orderProduct that has orderProductAttributes associated with it, update the graph and then save. It throws the following exception.
The relationship could not be changed because one or more of the foreign-key properties is non-nullable.
I'm sure it's something silly associated with the attribute, but I can't seem to figure it out.