From f6f589af06b4c0cf20feb49596598111bcb7a72f Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:08:52 -0800 Subject: [PATCH] Document IRelationalCommandDiagnosticsLogger.logCommandText parameter breaking change (#5181) Co-authored-by: Shay Rojansky --- .../ef-core-10.0/breaking-changes.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/entity-framework/core/what-is-new/ef-core-10.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-10.0/breaking-changes.md index d7801cf2d6..9b73433867 100644 --- a/entity-framework/core/what-is-new/ef-core-10.0/breaking-changes.md +++ b/entity-framework/core/what-is-new/ef-core-10.0/breaking-changes.md @@ -29,6 +29,7 @@ This page documents API and behavior changes that have the potential to break ex | [Complex type column names are now uniquified](#complex-type-column-uniquification) | Low | | [Nested complex type properties use full path in column names](#nested-complex-type-column-names) | Low | | [IDiscriminatorPropertySetConvention signature changed](#discriminator-convention-signature) | Low | +| [IRelationalCommandDiagnosticsLogger methods add logCommandText parameter](#logger-logcommandtext) | Low | ## Low-impact changes @@ -363,6 +364,45 @@ public virtual void ProcessDiscriminatorPropertySet( IConventionContext context) ``` + + +### IRelationalCommandDiagnosticsLogger methods add logCommandText parameter + +[Tracking Issue #35757](https://github.com/dotnet/efcore/issues/35757) + +#### Old behavior + +Previously, methods on `IRelationalCommandDiagnosticsLogger` such as `CommandReaderExecuting`, `CommandReaderExecuted`, `CommandScalarExecuting`, and others accepted a `command` parameter representing the database command being executed. + +#### New behavior + +Starting with EF Core 10.0, these methods now require an additional `logCommandText` parameter. This parameter contains the SQL command text that will be logged, which may have sensitive data redacted when is not enabled. + +#### Why + +This change supports the new feature to [redact inlined constants from logging by default](xref:core/what-is-new/ef-core-10.0/whatsnew#redact-inlined-constants-from-logging-by-default). When EF inlines parameter values into SQL (e.g., when using `EF.Constant()`), those values are now redacted from logs unless sensitive data logging is explicitly enabled. The `logCommandText` parameter provides the redacted SQL for logging purposes, while the `command` parameter contains the actual SQL that gets executed. + +#### Mitigations + +If you have a custom implementation of `IRelationalCommandDiagnosticsLogger`, you'll need to update your method signatures to include the new `logCommandText` parameter. For example: + +```c# +public InterceptionResult CommandReaderExecuting( + IRelationalConnection connection, + DbCommand command, + DbContext context, + Guid commandId, + Guid connectionId, + DateTimeOffset startTime, + string logCommandText) // New parameter +{ + // Use logCommandText for logging purposes + // Use command for execution-related logic +} +``` + +The `logCommandText` parameter contains the SQL to be logged (with inlined constants potentially redacted), while `command.CommandText` contains the actual SQL that will be executed against the database. + ## Microsoft.Data.Sqlite breaking changes