__EFMigrationsHistory table remains empty though update-database command applied

asp.net-core ef-migrations entity-framework-core

Question

I was applying an update-database command. suddenly an error popped up that Aspnetroles table already exist. Note that I have deleted several times the migration folder in the project. I have understood the entity framework is trying to apply all my previous migrations. then I checked my [dbo].[__EFMigrationsHistory] table and it was empty as shown as picture https://i.imgur.com/ed2jm8b.png

I have already tried deleting migration folder and drop all tables in the database. but it runs the first migration, creates the tables and does not keep any trace in migration history table in the database

another point that would be helpful that when I delete the migration folder and enter command enable-migrations then it gives warning me with yellow background:

Enable-Migrations is obsolete. Use Add-Migration to start using Migrations.

1
0
7/13/2019 1:41:16 PM

Accepted Answer

EF core does not use Enable-Migration any more.You need to use below code if you would like to add migrations:

Add-Migration MigrationName
Update-Database

Refer to https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/

1
7/15/2019 8:50:51 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow