IsModified is false when setting owned entity to null
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
Hi
I have a `SaveChangesInterceptor` where I check for changes in entries' properties and navigations and run business logic accordingly (for example, notifying other system about changes in the data). I've ran into an issue with references to owned entity types. I'm checking the `ReferenceEntry.IsModified` field to see if the references were changed and this works well in case of adding a new reference (i.e. from `null` to not `null`) and changing references (i.e. from not `null` to not `null`). However, when removing a reference (i.e. setting a not `null` reference to `null`) I see that `IsModified == false`.
This is an unintuitive behavior since the reference was indeed modified. I don't expect to have a reference to the deleted owned entity, just an indication that the current `null` set for the reference is a modification made in the current transaction.
I see that there was an issue report regarding this [back in 2022](https://github.com/dotnet/efcore/issues/27848) which was closed after an alternative was suggested for the OP's specific use case but the bug was never fixed.
Contributor guide
Assessment
This issue has not been assessed yet.