Add-Migration works, but Update-Database says "no migrations to update". I tried deleting the Mig.. Folder

John Murphy 25 Reputation points
2023-12-31T01:49:00.7366667+00:00

Visual Studio and EF Core problem. Migrations don't work. Add-Migration Title works to update the schema, but Update-Database in NuGet Command Console says that the db is already up to date, but the db does not have my new table in it.

I tried deleting the Migrations folder in the project. Have not tried to delete the Migrations History Table in the db for fear that if I can't update the db, then I would not be able to get a new

Migrations History table by the same token.

John

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
729 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,626 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 24,501 Reputation points Microsoft Vendor
    2024-01-01T03:09:46.6466667+00:00

    @John Murphy, Welcome to Microsoft Q&A,

    Based on your description, you meet an error when you use the Update-Database to add table to database.

    I recommend that you keep Migrations folder and delete all the migration files. Then you could run the command Add-Migration InitialCreate. Last you could run the Update-Database again.

    Please feel free to let me know if you have any questions.

    Best Regards,

    Jack


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.