Skip to content

Commit 3e12e53

Browse files
Add missing _migrationsAssemblyObject assignment in RelationalOptionsExtension copy constructor (#36136)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: AndriySvyryd <[email protected]>
1 parent fa93539 commit 3e12e53

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/EFCore.Relational/Infrastructure/RelationalOptionsExtension.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ protected RelationalOptionsExtension(RelationalOptionsExtension copyFrom)
6161
_useRelationalNulls = copyFrom._useRelationalNulls;
6262
_querySplittingBehavior = copyFrom._querySplittingBehavior;
6363
_migrationsAssembly = copyFrom._migrationsAssembly;
64+
_migrationsAssemblyObject = copyFrom._migrationsAssemblyObject;
6465
_migrationsHistoryTableName = copyFrom._migrationsHistoryTableName;
6566
_migrationsHistoryTableSchema = copyFrom._migrationsHistoryTableSchema;
6667
_executionStrategyFactory = copyFrom._executionStrategyFactory;

test/EFCore.Relational.Tests/Infrastructure/RelationalOptionsExtensionTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Reflection;
45
using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider;
56

67
// ReSharper disable InconsistentNaming
@@ -94,4 +95,25 @@ public void Throws_if_MinBatchSize_out_of_range()
9495
RelationalStrings.InvalidMinBatchSize(-1),
9596
Assert.Throws<InvalidOperationException>(
9697
() => new FakeRelationalOptionsExtension().WithMinBatchSize(-1)).Message);
98+
99+
[ConditionalFact]
100+
public void MigrationsAssemblyObject_is_preserved_after_cloning()
101+
{
102+
var optionsExtension = new FakeRelationalOptionsExtension();
103+
104+
// Get the current executing assembly
105+
var assembly = Assembly.GetExecutingAssembly();
106+
107+
// Set the migrations assembly
108+
optionsExtension = (FakeRelationalOptionsExtension)optionsExtension.WithMigrationsAssembly(assembly);
109+
110+
// Verify the migrations assembly object is set
111+
Assert.Same(assembly, optionsExtension.MigrationsAssemblyObject);
112+
113+
// Clone the options by using another With method (which internally calls Clone())
114+
optionsExtension = (FakeRelationalOptionsExtension)optionsExtension.WithCommandTimeout(100);
115+
116+
// Verify the migrations assembly object is still preserved after cloning
117+
Assert.Same(assembly, optionsExtension.MigrationsAssemblyObject);
118+
}
97119
}

0 commit comments

Comments
 (0)