burtonrodman / EntityFrameworkCore.Auditing

0 stars 0 forks source link

Throws exception on delete of a child entity with a 1-to-1 relationship to the root entity being saved by EF #10

Closed harlam357 closed 9 months ago

harlam357 commented 10 months ago

I have found a critical bug in the EF auditing code. I can demonstrate and have a work around code locally in my application on my machine. The issue arises when attempting to delete a child entity with a 1-to-1 relationship to the root entity being saved by EF.

The code that changes the state from Deleted to Modified, updates the ModifiedBy, and attempts to send the modification as an Update before Delete does not successfully update the row. Instead the row is still deleted and the subsequent attempt to actually Delete the row results in an exception.