Skip to content

Fix InMemory provider throwing on transaction use#37

Merged
Theauxm merged 1 commit intomainfrom
fix/inmemory-transaction-warning
Mar 19, 2026
Merged

Fix InMemory provider throwing on transaction use#37
Theauxm merged 1 commit intomainfrom
fix/inmemory-transaction-warning

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented Mar 19, 2026

Summary

Two related bugs in the InMemory provider:

  1. InMemoryContextProviderFactory didn't suppress TransactionIgnoredWarning, so any code path calling BeginTransaction (e.g. TraxScheduler.ScheduleManyAsync) threw instead of no-oping
  2. The factory and the scoped IDataContext registration in UseInMemory() each built their own DbContextOptions independently, which caused EF Core InMemory to create separate database roots — manifests written via ScheduleMany (factory path) were invisible to polling services (scoped path)

Fixed by introducing a shared InMemoryDatabaseRoot that both the factory and the scoped registration use, with a single BuildOptions method that configures the database name, root, and transaction warning suppression consistently.

Test plan

  • 30 InMemory integration tests pass (23 existing + 7 new)
  • FactoryContext_And_ScopedContext_ShareSameDatabase — writes via factory, reads via scoped context, confirms shared data
  • Transaction tests: begin, commit, rollback, cancellation token, entity persistence, ScheduleMany pattern
  • Full Trax.Effect solution test suite passes (all projects)
  • Zero build warnings, CSharpier formatted

The InMemory EF Core provider throws by default when transactions are
used. This breaks ScheduleMany and any other code path that calls
BeginTransaction on an InMemory context. Adding ConfigureWarnings to
ignore InMemoryEventId.TransactionIgnoredWarning lets transactions
no-op silently instead of throwing.
@Theauxm Theauxm merged commit 682d7b8 into main Mar 19, 2026
1 check passed
@Theauxm Theauxm deleted the fix/inmemory-transaction-warning branch March 19, 2026 17:24
@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented Mar 19, 2026

This PR is included in version 1.23.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant