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
- Create or use a project targeting .NET 10 with EF Core 10.0.x packages.
- Reference
Microsoft.EntityFrameworkCore.Tools 10.0.x.
- Do not explicitly reference
Microsoft.EntityFrameworkCore.Design.
- Restore packages.
- Inspect the resolved package graph.
- 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
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-Migrationfails with aMissingMethodException.Observed behavior
With a project using EF Core 10.0.x, adding only
Microsoft.EntityFrameworkCore.Tools10.0.x causes the resolved dependency graph to include:Microsoft.EntityFrameworkCore10.0.xMicrosoft.EntityFrameworkCore.Relational10.0.xMicrosoft.EntityFrameworkCore.Tools10.0.xMicrosoft.EntityFrameworkCore.Design8.0.0Then running
Add-Migrationfails during design-time execution with an exception like this:Expected behavior
Microsoft.EntityFrameworkCore.Tools10.0.x should resolve a matchingMicrosoft.EntityFrameworkCore.Design10.0.x dependency, or otherwise avoid introducing an older major version into the design-time dependency graph.Actual behavior
Microsoft.EntityFrameworkCore.Tools10.0.x resolvesMicrosoft.EntityFrameworkCore.Design8.0.0, which then loads EF Core design-time assemblies incompatible with EF Core 10.0.x runtime assemblies.Repro
Microsoft.EntityFrameworkCore.Tools10.0.x.Microsoft.EntityFrameworkCore.Design.Add-Migration.Example result from package resolution:
Microsoft.EntityFrameworkCore.Tools10.0.8Microsoft.EntityFrameworkCore.Design8.0.0Workaround
Adding an explicit direct reference to
Microsoft.EntityFrameworkCore.Design10.0.x fixes the issue immediately, because the direct dependency overrides the transitive 8.0.0 version.For example, explicitly referencing
Microsoft.EntityFrameworkCore.Design10.0.8 makesAdd-Migrationwork again.Additional notes
I checked the package metadata in the restored NuGet package, and the nuspec for
Microsoft.EntityFrameworkCore.Tools10.0.8 declares:So this looks like a package dependency metadata issue rather than a local project configuration problem.
Your code
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