Entity Framework Core Migrations within an Agile Team

Ramy Gamal 1 Reputation point
2022-10-31T19:08:03.59+00:00

Hello everyone!

I would like to get some advice on working with EFCORE 6 within an agile team.

What is the best and common way of handling EFCORE migrations within teams? we need to make it easy to apply and rollback features that may involve some database migrations. We have multiple product environments as staging environment where the QA team validates all the stuff, and production environment which is, the live version.

Let's have an Example we were working on 3 features: A, B, and C. and all of them contain database migrations which are already applied to the staging environment in ABC order.

The QA team decided that feature B is not ready yet to be live, although we need to deploy features A and C.

So what should we do in that case?

  1. remove C migration then B migration and then apply C only?
  2. remove B migrations using git ? I think this will ruin the migrations snapshots.
  3. Make a new migration reverting the work done in B migration?

Or there is another, better way of doing this. Will be glad to hear your thoughts!

Thanks

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zhanglong Wu-MSFT 261 Reputation points Microsoft Vendor
    2022-11-01T05:46:30.577+00:00

    @Ramy Gamal ,

    Based on your description, it seems that you want to update the database to a specified migration and rollback, if so, Entity Framework Core tools "Update-Database" can reach it. like below:

    Update-Database 20180904195021_InitialCreate -Connection your_connection_string  
    

    And you use "Remove-Migration" to remove the last migration (rolls back the code changes that were done for the migration).

    In addition, you could also generate a SQL script by using "Script-Migration" or "Script-DbContext", and choose your required script to execute on your database.

    For more information, please refer to: Entity Framework Core tools reference

    Best regards,
    Zhanglong

    0 comments No comments