ulnagar / Constellation

0 stars 0 forks source link

Removing last student from family causes EF errors in update #54

Closed ulnagar closed 1 year ago

ulnagar commented 1 year ago

When removing the last student from the family, it triggers the StudentRemovedFromFamilyDomainEvent_EnsureFamilyHasActiveStudents domain event. This event tried to delete the family if there are no students remaining linked to it. First it deletes each parent and then soft-deletes the family.

Parents are not being deleted. Instead EFCore is attempting to set the FK to null (not a valid entry), which crashes the entire transaction.

ulnagar commented 1 year ago

Tested without issue. Scheduled to be released to production with R1.11.1