hoeyi / Ozym

A web-application for tracking personal finances. Built using Blazor, ASP.NET Core, and Entity Framework Core.
3 stars 0 forks source link

ModelWriterService fails when attempting to save modified child graph #80

Closed hoeyi closed 2 years ago

hoeyi commented 2 years ago

Describe the bug Updates the child model elements when using the parent ModelWriterService implementation fails because one row is expected to be modified, but zero actually are.

To Reproduce Steps to reproduce the behavior:

  1. Load aInvestmentStrategy instance with child InvestmentStrategyTarget instances.
  2. Update attributes of the child models.
  3. Save the InvestmentStrategy instance using ModelWriterServer.UpdateAsync method.
  4. See DbUpdateConcurrencyException with the following error message:

The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded.

Expected behavior The update action should account for related records, and update the entire attached object graph.

Additional context First identified in commit 3a526f4b71cf70cc65c2f4a1a88a44b0e773392e.

hoeyi commented 2 years ago

Fixed in https://github.com/hoeyi/Njord-Finance/commit/9aea97b983f68bb625fdfe65aa6f9c0d1d6e07db, but has opportunity for a generic approach.