Payroll Data Integrity and Transactions
Summary
Confirmed SaveChanges boundaries, atomic local writes, and external boundaries.
Audience
Payroll developers, QA and support engineers, solution and security architects, and implementation partners.
Purpose
Document local atomicity and the work that occurs outside Payroll EF transactions.
Ownership
Payroll application services define SaveChanges boundaries. No explicit BeginTransaction call is present in Payroll Service source.
Lifecycle
Each SaveChanges call receives the provider's normal atomic commit behavior for staged changes. Native calculate/freeze/unfreeze stage run state, details or recoveries, audit, timeline, and outbox intent before one save. Structured payslip generation stages payslip, audit, and outbox before one save. Projection synchronization stages projection, processed marker, and audit before one save.
Persisted fields
Integrity relies on primary keys, selected unique indexes, required/length mappings, fixed-precision numbers, and application validation.
Relationships
No foreign keys, cascades, concurrency tokens, owned types, or navigation relationships are configured.
Constraints
Uniqueness protects only the ten documented identities. Application logic must validate logical references and state transitions.
Indexes
Indexes support lookup/idempotency but do not make multi-save workflows atomic.
Tenant behavior
Local atomicity does not validate tenant correctness. Global filters or explicit predicates must still scope every query/write.
Audit behavior
Audit/timeline are atomic with business writes only when staged before the same SaveChanges call. Report/export audit is saved after read/file preparation. Backfill target batches and their completion-audit records use separate contexts/saves.
Integration usage
Outbox intent can share a local transaction; actual broker publication does not. Inbound broker acknowledgement follows projection commit, while failures are negatively acknowledged for requeue. PDF rendering, file generation, notifications, and other external services are outside the EF transaction.
Known limitations
No distributed transaction, database-enforced referential integrity, optimistic concurrency control, or universal unit-of-work boundary is confirmed.
Requires confirmation
- Idempotency/recovery for failures between separate saves or external steps.
- Concurrency strategy for simultaneous Payroll commands.
- Formal reconciliation of committed outbox intent and downstream delivery.
Source References
microservices/src/payroll-service/Infrastructure/PayrollDbContext.csmicroservices/src/payroll-service/Domain/PayrollEntities.csmicroservices/src/payroll-service/Infrastructure/Migrations/PayrollDbContextModelSnapshot.csmicroservices/src/payroll-service/Application/PayrollCalculationService.csmicroservices/src/payroll-service/Application/PayrollOutputsService.csmicroservices/src/payroll-service/Messaging/PayrollReadModelConsumer.csmicroservices/src/payroll-service/Backfill/BackfillStepBase.cs
Related Articles
See Also
Keywords
- Payroll database
- Payroll Data Integrity and Transactions
- Payroll persistence
Revision Information
- Status: Draft
- Last reviewed: 2026-07-15
- Review cycle: Quarterly