Skip to content

Breaking change note: FromSql/SqlQuery throw for same-named DbParameters referenced by name - #5516

Draft
ajcvickers wants to merge 1 commit into
dotnet:mainfrom
ajcvickers:breaking-change-fromsql-duplicate-dbparameter-names
Draft

ajcvickers wants to merge 1 commit into
dotnet:mainfrom
ajcvickers:breaking-change-fromsql-duplicate-dbparameter-names

Conversation

@ajcvickers

Copy link
Copy Markdown
Contributor

Documents the EF Core 12 breaking change from dotnet/efcore#39593 (fixes dotnet/efcore#32932): FromSqlRaw/SqlQueryRaw now throw when same-named DbParameters 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.md doesn't exist on main yet 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

…ers referenced by name

Documents the EF Core 12 change from dotnet/efcore#32932.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Documentation changes are still needed to scope the breaking-change summary to raw APIs, register the new page in navigation, and document the mixed-reference limitation.

3 open issues

Review effort: Lite

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.
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.

Parameter value mixup

2 participants