Skip to content

IsModified is false when setting owned entity to null #36368

@alonl153

Description

@alonl153

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 which was closed after an alternative was suggested for the OP's specific use case but the bug was never fixed.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions