Skip to content

Microsoft.EntityFrameworkCore.Tools 10.0.6+ resolves Microsoft.EntityFrameworkCore.Design 8.0.0, causing Add-Migration to fail #38325

@dashiell-zhang

Description

@dashiell-zhang

Bug description

Microsoft.EntityFrameworkCore.Tools version 10.0.6 and later appears to bring in Microsoft.EntityFrameworkCore.Design 8.0.0 as a transitive dependency.

This causes a design-time/runtime mismatch when a project is using EF Core 10.0.x packages, and Add-Migration fails with a MissingMethodException.

Observed behavior

With a project using EF Core 10.0.x, adding only Microsoft.EntityFrameworkCore.Tools 10.0.x causes the resolved dependency graph to include:

  • Microsoft.EntityFrameworkCore 10.0.x
  • Microsoft.EntityFrameworkCore.Relational 10.0.x
  • Microsoft.EntityFrameworkCore.Tools 10.0.x
  • Microsoft.EntityFrameworkCore.Design 8.0.0

Then running Add-Migration fails during design-time execution with an exception like this:

System.MissingMethodException: Method not found: 'System.String Microsoft.EntityFrameworkCore.Diagnostics.AbstractionsStrings.ArgumentIsEmpty(System.Object)'.
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Method not found: 'System.String Microsoft.EntityFrameworkCore.Diagnostics.AbstractionsStrings.ArgumentIsEmpty(System.Object)'.

Expected behavior

Microsoft.EntityFrameworkCore.Tools 10.0.x should resolve a matching Microsoft.EntityFrameworkCore.Design 10.0.x dependency, or otherwise avoid introducing an older major version into the design-time dependency graph.

Actual behavior

Microsoft.EntityFrameworkCore.Tools 10.0.x resolves Microsoft.EntityFrameworkCore.Design 8.0.0, which then loads EF Core design-time assemblies incompatible with EF Core 10.0.x runtime assemblies.

Repro

  1. Create or use a project targeting .NET 10 with EF Core 10.0.x packages.
  2. Reference Microsoft.EntityFrameworkCore.Tools 10.0.x.
  3. Do not explicitly reference Microsoft.EntityFrameworkCore.Design.
  4. Restore packages.
  5. Inspect the resolved package graph.
  6. Run Add-Migration.

Example result from package resolution:

  • Microsoft.EntityFrameworkCore.Tools 10.0.8
  • Microsoft.EntityFrameworkCore.Design 8.0.0

Workaround

Adding an explicit direct reference to Microsoft.EntityFrameworkCore.Design 10.0.x fixes the issue immediately, because the direct dependency overrides the transitive 8.0.0 version.

For example, explicitly referencing Microsoft.EntityFrameworkCore.Design 10.0.8 makes Add-Migration work again.

Additional notes

I checked the package metadata in the restored NuGet package, and the nuspec for Microsoft.EntityFrameworkCore.Tools 10.0.8 declares:

<group targetFramework="net8.0">
  <dependency id="Microsoft.EntityFrameworkCore.Design" version="8.0.0" />
</group>

So this looks like a package dependency metadata issue rather than a local project configuration problem.

Your code

PM> Add-Migration Init

Build started...
Build succeeded.
System.MissingMethodException: Method not found: 'System.String Microsoft.EntityFrameworkCore.Diagnostics.AbstractionsStrings.ArgumentIsEmpty(System.Object)'.
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Method not found: 'System.String Microsoft.EntityFrameworkCore.Diagnostics.AbstractionsStrings.ArgumentIsEmpty(System.Object)'.

Stack traces

Verbose output

EF Core version

10.0.8

Database provider

Microsoft.EntityFrameworkCore.SqlServer

Target framework

.NET 10

Operating system

Windows 11

IDE

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions