Designing a ledger: balances should be derived from transactions
A balance column tells you a number. A ledger tells you why. How to make recorded transactions the single source of truth for a wallet, with runnable EF Core code.
A balance column tells you a number. A ledger tells you why. How to make recorded transactions the single source of truth for a wallet, with runnable EF Core code.
Two withdrawals read the same balance and both succeed: that's a race condition. Three ways to stop it in EF Core (rowversion, an atomic update, and a row lock) and when to use each.