EF-Core Update-Database command fails (cannot load type from Microsoft.EntityFramework.Design

.net ef-migrations entity-framework-core visual-studio-2017


I cannot run my migrations - this is very annoying as I cannot move on with my project...

I think it must be something with ef tooling because some time back (one month) the migrations in this project worked.

The Add-Migration command works successfully, but subsequent Update-Database fail with following error:

Applying migration '20181129154443_strlen'.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
 ---> System.Runtime.Remoting.RemotingException: 
 Cannot load type
 Microsoft.EntityFrameworkCore.Design, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Some maybe relevant info:

  • All project in solution depends on same packages (ie. Microsoft.EntityFrameworkCore.Design, Version= etc.)
  • Project containing DbContext is using package reference style instead of packages.config (do not ask me why)
  • Startup project is using classic packages.config
  • all projects in solution are targeting .NET framework 4.7.2
  • whole solution builds and runs just fine (when I remove the pending migrations)
  • Add-Migration command works just fine (generates migration code file, happens for any type of change (does not matter if i am changing column name or add index))
  • I have all of the .NET Core tooling (sdk, runtime) versions installed

There is similar question (unanswered): EF core migration failed: System.Runtime.Remoting.RemotingException: Cannot load type 'Microsoft.EntityFrameworkCore.Design.IOperationResultHandler but none of the suggestions there did not helped me.

What I have tried:

  1. Restart VisualStudio, clean .vs
  2. Cleared all NugetCaches, deleted packages folder
  3. Delete bin/obj folders
  4. Restarted pc
  5. Checked version of NetCore sdk and runtime versions
11/30/2018 10:03:56 AM

Accepted Answer

Solution for me was to convert all of the projects in solution from 4.7.2 to .NET Core 2.2. (also all the NuGets (EFCore, EFCore.Design) were upgraded to v2.2.2). After that the migrations started to work.

2/20/2019 2:56:37 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow