Repository navigation
Breaking change note: FromSql/SqlQuery throw for same-named DbParameters referenced by name - #5516
Draft
ajcvickers wants to merge 1 commit into
Draft
ajcvickers wants to merge 1 commit into
ajcvickers wants to merge 1 commit into
Conversation
…ers referenced by name Documents the EF Core 12 change from dotnet/efcore#32932. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comment on lines
+1
to
+7
| --- | ||
| title: Breaking changes in EF Core 12 (EF12) - EF Core | ||
| description: List of breaking changes introduced in Entity Framework Core 12 (EF12) | ||
| author: ajcvickers | ||
| ms.date: 11/10/2026 | ||
| uid: core/what-is-new/ef-core-12.0/breaking-changes | ||
| --- |
|
|
||
| | **Breaking change** | **Impact** | | ||
| |:------------------------------------------------------------------------------------------------------------------------ | -----------| | ||
| | [`FromSql` and `SqlQuery` now throw for same-named `DbParameter`s that are referenced by name in the SQL](#fromsql-duplicate-parameter-names) | Low | |
Comment on lines
+54
to
+56
| Starting with EF Core 12, an <xref:System.InvalidOperationException> is thrown when a `DbParameter` would need to be renamed because another parameter in the same query has the same name, and the SQL passed to `FromSqlRaw` or `SqlQueryRaw` does not refer to that parameter positionally. This also applies when the parameters have equal values, and when the name conflicts with a parameter name generated by EF Core, such as `p0`. | ||
|
|
||
| Queries that refer to every parameter positionally, or that use a distinct name for each parameter, are not affected. `FromSql` and `SqlQuery` with interpolated strings always use positional parameters, and are not affected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Documents the EF Core 12 breaking change from dotnet/efcore#39593 (fixes dotnet/efcore#32932):
FromSqlRaw/SqlQueryRawnow throw when same-namedDbParameters are referenced by name in the SQL, instead of silently using the first parameter's value for all of them.Includes old/new behavior, rationale, and mitigations (distinct names, or positional
{0}placeholders).Note:
ef-core-12.0/breaking-changes.mddoesn't exist onmainyet and is also added by #5511 and #5515, using the same page skeleton. Whichever merges first, the others need a trivial rebase of that file (summary table row and section).🤖 Generated with Claude Code