__EFMigrationsHistory table remains empty though update-database command applied

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.sstatic.net/jOgYO.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.

Upvotes: 0

Views: 2065

Answers (1)

Ryan
Ryan

Reputation: 20141

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://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/

Upvotes: 2

Related Questions