Skip to content

Take the database offline when a BuildContext context is disposed - #1089

Closed
SimonCropp wants to merge 2 commits into
mainfrom
fix-buildcontext-auto-offline
Closed

SimonCropp wants to merge 2 commits into
mainfrom
fix-buildcontext-auto-offline

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

Fixes the failing `EfLocalDb.Tests.SimpleContext` on CI (run 2 on main).

`BuildContext` disposed its `SqlDatabase` before returning the context. With auto offline on (the default on CI), that took the database offline before the caller could use it, giving `SqlException 4060: Cannot open database ... Login failed`.

  • `BuildContext` now hands the take-offline step to the returned context via a `TakeOfflineInterceptor`, which takes the database offline when the context's connection is disposed.
  • `NewConnectionOwnedDbContext` keeps its public behaviour; the hand-over is an internal overload.
  • Adds `BuildContext_AutoOffline`, which forces `dbAutoOffline: true` so it no longer depends on the CI environment. It fails without the fix.

EfClassicLocalDb has no `BuildContext`, so it is unaffected.

SimonCropp and others added 2 commits September 24, 2026 21:16
…t when BuildContext returns

BuildContext disposed its SqlDatabase before returning the context, so with auto offline on (the default on CI) the database was offline before the caller could use it.
@SimonCropp SimonCropp closed this Sep 24, 2026
@SimonCropp
SimonCropp deleted the fix-buildcontext-auto-offline branch September 24, 2026 12:07
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.

2 participants