Kuartz
Kuartz

Reputation: 302

Reset Migrations from Entity Framework Core

I would like to reset Entity Framework migrations as if I had never used this functionality.

I tried to :

  1. Delete Migrations folder
  2. Delete table "dbo._EFMigrationsHistory"
  3. Then type: Add-Migration Initial

The result is :

namespace fretapp.Migrations
{
    public partial class Test : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {

        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {

        }
    }
}

I deleted all the tables from my database, but the models in API are still here, so It should update the database, but no code here.

Then I tried to :

  1. Delete Migrations folder
  2. DROP database
  3. Create a new database with a new name
  4. Change connexion string in the database context
  5. I got exactly the same result...

So where are the data from migrations stored???

Thank you in advance.

Upvotes: 1

Views: 2503

Answers (1)

Vivek Nuna
Vivek Nuna

Reputation: 1

You can undo all the migration by using the below command.

Update-Database -Target:0

Or you run the below command

Update-Database <First MigrationName>

so all the migration will be undone, then you can make the changes and generate the new migration and proceed with the work.

Upvotes: 1

Related Questions