Pass DbContext to RelationalCommandParameterObject #36286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make
DbContext
available fromRelationalCommandParameterObject
for interception with SQLite and querying enumerables.The functionality to add the context to the interception was added originally by #16162, but the context wasn't passed through for SQLite for some reason.
I found this by chance via some changes for OpenTelemetry in open-telemetry/opentelemetry-dotnet-contrib#2829 where an exception was being thrown internally due to an assumption that the context is always non-null here and here.
It's used in
SqliteHistoryRepository
here, but not in the other two locations for SQLite, which this PR changes.efcore/src/EFCore.Sqlite.Core/Migrations/Internal/SqliteHistoryRepository.cs
Line 225 in 0e9f58b
While I was at it, I looked at all the other call sites for the constructor and changed any that had access to the DbContext but also just passed through null.
I haven't added any tests for this as it wasn't obvious to me where to add/edit existing tests for this. There wasn't any obvious SQLite-specific place to put tests based on reviewing the diff from #16162. I can add some if some guidance is provided on where they should go.