Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
baratgabor opened this issue Feb 28, 2021 · 0 comments
Open
Labels
backend bug Something isn't working

Comments

@baratgabor
Copy link
Owner

baratgabor commented Feb 28, 2021

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.
@baratgabor baratgabor added bug Something isn't working backend labels Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant