The string argument 'migrationId' cannot be empty c# ef-migrations entity-framework-core


Apologies in advance if this has already been answered but I've honestly dug deep and could not find anything relating to this error.

In a nutshell, I am unable to make any updates to my database using code first within my ASP.NET Core 1.1.2 project. It's throwing an exception because it's missing an argument which I'm guessing is not to do with PMC.

Error message when using 'Update-Database':


Text for cross checking Google ;-)

    System.ArgumentException: The string argument 'migrationId' cannot be empty.
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.GetAppliedMigrations()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The string argument 'migrationId' cannot be empty.

The Migrations folder is identical to my '_EFMigrationsHistory' table (ignoring the last migration which is scheduled for update):

enter image description here

I've even gone as far as removing the Migrations folder and '_EFMigrationsHistory' table and starting again which presented the same error. I was also going to test 'v2.0.0-preview2-final' just in case it was a bug, but sadly my version of VS only takes release builds and apparently you need 15.3.

Version Info:

  • Visual Studio Enterprise 2017 - 15.2 (26430.16) Release
  • Entity Framework Core v1.1.2
  • ASP.NET Core v1.1.2

Any pointers would be much appreciated.



For dotnet ef database update

enter image description here

and for Update-Database -TargetMigration AdUserImage

enter image description here

7/24/2017 4:14:57 PM

Accepted Answer

I finally resolved the issue thanks to @DavidG putting me on the right direction so thank you very much.

I realised that when I was checking the installed SDK's on my PC, I noticed that I've installed a pre-release of Dotnet 2.0.0 (I honestly can't remember doing this). Checking the Dotnet version (dotnet --version) from PMC confirmed VS was using 2.0.0. After uninstalling all Dotnet SDK's and runtimes and then re-installing the latest release of Dotnet(1.1.2) from here, Update-Database was working as should...few!

7/24/2017 3:25:33 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