Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Core add-migration Build Failed

I have a developer that is getting "Build failed." when running add-migration in a .NET Core EF project, with no explanation of why the build failed. How do you troubleshoot this error?

This is what he gets in the Package Manager Console:enter image description here

Additional information:

We have a few other developers using the same solution code (myself included) that have not issues with add-migration.

This is what I see in Package Manager Console:enter image description here

We've verified that the project builds, and the entire solution builds. We've done "dotnet restore" and rebuild all multiple times, in addition to restarting VS2015. We've verified that the correct default solution is selected both in Solution Explorer, and in the Package Manager Console drop-down. We've verified that he has the correct SDK installed on his machine. I'm at a loss as to what to check next...any time I've had a failure during add-migration I've gotten enough information to point me in the direction of what to check, but just "Build failed." is a fairly useless error output.

like image 274
jceddy Avatar asked Jun 27 '17 16:06

jceddy


People also ask

Why does add migration fail?

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.

Does EF core support automatic migration?

EF core doesn't support automatic migrations . So you have to do it manually.

How do I get rid of migration EF core?

Delete your Migrations folder. Create a new migration and generate a SQL script for it. In your database, delete all rows from the migrations history table. Insert a single row into the migrations history, to record that the first migration has already been applied, since your tables are already there.


1 Answers

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.

like image 198
mmh18 Avatar answered Sep 24 '22 14:09

mmh18