diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs
index 81fa31b5873..c0de298d5ff 100644
--- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs
+++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs
@@ -20,6 +20,9 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal
///
public class SqlServerTransaction : RelationalTransaction
{
+ private static readonly bool _useOldBehavior
+ = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23350", out var enabled) && enabled;
+
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -49,6 +52,11 @@ public override bool SupportsSavepoints
{
get
{
+ if (_useOldBehavior)
+ {
+ return base.SupportsSavepoints;
+ }
+
if (Connection is ISqlServerConnection sqlServerConnection && sqlServerConnection.IsMultipleActiveResultSetsEnabled)
{
Logger.SavepointsDisabledBecauseOfMARS();
diff --git a/src/EFCore/Diagnostics/WarningsConfiguration.cs b/src/EFCore/Diagnostics/WarningsConfiguration.cs
index e89b81c44d4..c64d94e022e 100644
--- a/src/EFCore/Diagnostics/WarningsConfiguration.cs
+++ b/src/EFCore/Diagnostics/WarningsConfiguration.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
@@ -21,6 +22,9 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics
///
public class WarningsConfiguration
{
+ private static readonly bool _useOldBehavior
+ = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23350", out var enabled) && enabled;
+
private Dictionary _explicitBehaviors
= new Dictionary();
@@ -172,7 +176,14 @@ public virtual long GetServiceProviderHashCode()
if (_explicitBehaviors != null)
{
- hashCode = _explicitBehaviors.OrderBy(b => b.Key).Aggregate(
+ IEnumerable> explicitBehaviors = _explicitBehaviors;
+
+ if (!_useOldBehavior)
+ {
+ explicitBehaviors = _explicitBehaviors.OrderBy(b => b.Key);
+ }
+
+ hashCode = explicitBehaviors.Aggregate(
hashCode,
(t, e) => (t * 397) ^ (((long)e.Value.GetHashCode() * 3163) ^ (long)e.Key.GetHashCode()));
}