EF Core add-migration Build Failed

I had the exact same problem (.NET Core 2.0.1).

Sometimes it helps if the project is rebuilt.

I also encounter the problem when I opened the project in 2 Visual Studios.
Closing one Visual Studio fixed the error.

  • Ctrl + C (first stop the application from running, this alone might be enough!)
  • dotnet run build
  • dotnet ef migrations add InitialCreate

It's because of other projects in your solutions. e.g If you have two projects in your solution as Project A and Project B. If Project A is not successful build and then Project B data migration will fail. So you should unload Project A and add the migration to Project B again.

I think this is not a good answer but hope this help.