EF Core - Table '*.__EFMigrationsHistory' doesn't exist

Turning Mark G's comment into an answer.

Once the __EFMigrationsHistory table has been created, the rest of the update should run.

CREATE TABLE `__EFMigrationsHistory` ( `MigrationId` nvarchar(150) NOT NULL, `ProductVersion` nvarchar(32) NOT NULL, PRIMARY KEY (`MigrationId`) );

Alternatively, generate the script of your migration(s) and apply to the database manually using this command in Package Manager Console:

Script-Migration

If you need to generate All scripts, you can use this command:

Script-Migration -from 0

Encountered the same problem while using standard Oracle provider.

According to this question Dot Net Entity Framework database update doesn't create tables in mysql database it doesn't have the migrations feature implemented yet.

I followed the suggestions the switched to SapientGuardian provider and it does seem to be the best way to go now.

Edit: as suggested in comments Pomelo is the best option as of beggining of 2018. I've chosen it over other providers since my original answer.


I run into the same issue, OP context might be slightly different but here is my answer for sake of completeness.

One of the ways you can run into this problem is if:

  • You create a migration and update the database,
  • Later for some reason you drop your tables (not the database) and try to run the update-databse command once again.

In that case you will get the error reported by OP

MySql.Data.MySqlClient.MySqlException: Table 'db.__EFMigrationsHistory' doesn't exist

The solution in this case, is to drop the complete database. After that the update-databse command runs sucessfuly.

I'm not sure if its related to mysql only, but to resume :

  • If you drop the tables but use an existing database (which had previous migrations), the update command will give you an exception.
  • If you drop the complete database, the update command will run perfectly.