Home  >  Q&A  >  body text

How to resume database migration

I have a mysql database but I can't delete it. I'm missing my migration files in an asp.net project and I made some changes in the dbcontext file.

When I try to create a new migration and update the database, it shows that table 'aspnetroles' already exists. what do I do? How to revert migration or how to make migration and database equal?

P粉418214279P粉418214279407 days ago538

reply all(1)I'll reply

  • P粉337385922

    P粉3373859222023-09-09 18:32:20

    EF Core Migrations' dotnet ef database update will attempt to update the database to the latest migrations. It will query the __EFMigrationsHistory table to see which migrations have been applied and which ones still need to be applied (if any).

    The solution to some problems is to simulate the updates being applied by manually inserting the migration history. This avoids deleting the database, which can be problematic in a production environment.

    Insert records into the development database as follows:

    MigrationId ProductVersion
    20230516084711_Initial 7.0.5

    reply
    0
  • Cancelreply