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.
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.