EF Core add-migration Build Failed
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.
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.