Skip to content

Some entity modifications don't update LastModifiedBy/LastModifiedAt #22

@baratgabor

Description

@baratgabor

When certain properties of the domain entities (e.g. Product) are modified, it would be expected for the backend to update the LastModifiedAt and LastModifiedBy audit fields on the given entity.

But this doesn't happen, because certain properties are value objects, configured as EF Core owned type navigation properties. For example updating the price of a product fails to update the two aforementioned fields on the given product entity; even though the modification involves assigning a completely new Money instance to the property, since they are immutable.

I'm actually not sure if this is a glitch due to EF Core's slightly sketchy support for owned types (or perhaps navigation properties that have value conversion configured), OR actually normal expected behavior.

But in either case, it would be probably better to move the responsibility of setting these properties right into the domain entities, because arguably it's a domain concern that entities should have properly set last modified fields.

Tasks:

  • Make sure all modifications of domain entities lead to updated LastModified fields.
  • Consider moving this responsibility from DbContext right into the domain entities (possibly with the help of MyEntity abstract base class).
  • Also check and possibly expand the integration tests... it seems these things aren't covered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions