Skip to content

_migrationsAssemblyObject is missing from RelationalOptionsExtension copy constructor #36053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
inkysquid opened this issue May 8, 2025 · 1 comment

Comments

@inkysquid
Copy link

Bug description

I discovered that RelationalDbContextOptionsBuilder.MigrationsAssembly() method must be called last, otherwise the assembly object is removed.

This is because WithOption method makes a clone of the options builder, but the RelationalOptionsExtension constructor is silly and forgets to copy the _migrationsAssemblyObject field.

I would make a PR, but I am scared.

Your code

My code? It's not my code!


/// <summary>
///     Called by a derived class constructor when implementing the <see cref="Clone" /> method.
/// </summary>
/// <param name="copyFrom">The instance that is being cloned.</param>
protected RelationalOptionsExtension(RelationalOptionsExtension copyFrom)
{
    _connectionString = copyFrom._connectionString;
    _connection = copyFrom._connection;
    _connectionOwned = copyFrom._connectionOwned;
    _commandTimeout = copyFrom._commandTimeout;
    _maxBatchSize = copyFrom._maxBatchSize;
    _minBatchSize = copyFrom._minBatchSize;
    _useRelationalNulls = copyFrom._useRelationalNulls;
    _querySplittingBehavior = copyFrom._querySplittingBehavior;
    _migrationsAssembly = copyFrom._migrationsAssembly;
    // See here for conspicuously missing assignment to_migrationsAssemblyObject
    _migrationsHistoryTableName = copyFrom._migrationsHistoryTableName;
    _migrationsHistoryTableSchema = copyFrom._migrationsHistoryTableSchema;
    _executionStrategyFactory = copyFrom._executionStrategyFactory;
    _parameterizedCollectionTranslationMode = copyFrom._parameterizedCollectionTranslationMode;
}

Stack traces


Verbose output


EF Core version

9.0.4

Database provider

No response

Target framework

No response

Operating system

No response

IDE

No response

@maumar
Copy link
Contributor

maumar commented May 9, 2025

Thanks for reporting @inkysquid PR would be very welcome! You can also add as simple test in RelationalOptionsExtensionTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants