Repository navigation
Description
Background
UltimateAuth uses multiple EF Core persistence stores across its authentication, sessions, credentials, tokens, users, and authorization domains.
Some stores manage transactions through ExecuteAsync, while others persist changes directly using SaveChangesAsync.
Following #96, credential changes and session revocation support atomic execution when participating in a shared EF Core transaction.
However, transaction ownership, execution strategy handling, and transaction participation are not yet standardized across all EF Core stores.
Goal
Establish consistent transaction execution semantics across UltimateAuth's EF Core persistence implementations without introducing unnecessary coupling between domain stores.
Scope
1. Standardize transaction participation
Review all EF Core stores that initiate transactions or expose ExecuteAsync.
Ensure consistent behavior:
- Start a transaction when required and no transaction exists.
- Participate in an existing transaction without creating nested transactions.
- Commit or roll back only transactions owned by the current execution scope.
- Propagate failures to the outer transaction owner.
- Preserve existing concurrency and cancellation semantics.
2. Review execution strategy integration
Ensure compatibility with EF Core execution strategies, including providers that support transient failure retries.
Evaluate retry safety, transaction ownership, and potential side effects.
3. Evaluate shared execution infrastructure
Consider introducing a reusable EF Core transaction execution component to avoid duplicating transaction management logic across stores.
Keep domain-specific execution rules and persistence responsibilities separate.
4. Define multi-DbContext guarantees
UltimateAuth supports both unified and domain-specific DbContext configurations.
Review transaction behavior when multiple contexts participate in a single logical operation.
Determine which atomicity guarantees can be supported and document any limitations.
Do not assume that independent DbContext instances automatically share transactions.
5. Expand integration tests
Add regression coverage for:
- Standalone store execution.
- Participation in existing transactions.
- Nested execution scenarios.
- Successful commits and rollbacks.
- Cross-store atomic operations.
- Concurrency conflicts.
- Provider-specific execution strategy behavior where applicable.
Acceptance Criteria
- EF Core transaction ownership rules are consistent across stores.
- Nested transaction conflicts are prevented.
- Existing transactions are respected.
- Execution strategy behavior is documented and tested.
- Shared execution infrastructure is evaluated and implemented if beneficial.
- Unified and separate
DbContextconfigurations have explicitly defined atomicity guarantees. - Existing authentication and persistence behavior remains backward compatible.
- Relevant integration tests pass.
Notes
This issue is an architectural improvement planned for v0.2.0.
It should not introduce new authentication features or unnecessary public API changes.
Related: #96.
Activity