'Fragment' does not have an implementation exception when trying to add migration with EF Core 7

8.3k Views Asked by At

When I'm trying to add a migration using EF Core (7.0.0-rc.1.22426.7) I'm greeted with the following error in the console:

System.TypeLoadException: Method 'Fragment' in type 'Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper' from assembly 'Microsoft.EntityFrameworkCore.Design, Version=6.0.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
   at Microsoft.EntityFrameworkCore.Design.DesignTimeServiceCollectionExtensions.<>c__DisplayClass0_0.<AddEntityFrameworkDesignTimeServices>b__0(ServiceCollectionMap services)
   at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.TryAddProviderSpecificServices(Action`1 serviceMap)
   at Microsoft.EntityFrameworkCore.Design.DesignTimeServiceCollectionExtensions.AddEntityFrameworkDesignTimeServices(IServiceCollection services, IOperationReporter reporter, Func`1 applicationServiceProviderAccessor)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.CreateServiceCollection(DbContext context)
   at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(DbContext context)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
   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 'Fragment' in type 'Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper' from assembly 'Microsoft.EntityFrameworkCore.Design, Version=6.0.8.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.

Has anyone encountered this before and know what to do about it? Migrations worked up until today and I don't think I've been adding very exotic things to my code base. Any pointers in the right direction are helpful since Google didn't really clarify anything yet...

2

There are 2 best solutions below

0
Mohamed Ali On

Installing Microsoft.EntityFrameworkCore.Design solved the problem for me

1
Ewan On

First time I tried I received that message also. There was another warning "The Entity Framework tools version '6.0.13' is older than that of the runtime '7.0.2'. Update the tools for the latest features and bug fixes."

So I updated the Microsoft.EntityFrameworkCore.Tools to 7.0.2 to be the same as Microsoft.EntityFrameworkCore.SqlServer and that fixed it