I'm trying to update an object graph that contains ICollection of modified/added/deleted entities in a detached scenario (short lived context), using EF 5.0?
I have something like this:
Visit (Edited)
FinancialInfo (Unchanged)
Discount1 (Added)
Discount2 (Modified)
Discount3 (Deleted)
When I try to update visit it throws OptimisticConcurrency exception:
"Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries."
Actually I know what is causing the problem, but I'm using a repository pattern, I do not use DbContext directly.
I could write custom update logic for Visit entity which would handle the issue, but I'm looking for a generic option.
This makes me think that, probably there's no hustle free approach, but anyway...
Any advice will be appreciated.
Thank you