EF migration on startup in case of more than one replica
Hello, I think doing migration on app startup is not good idea in case there will be more than one replica in k8s. Currently there is only one so it works fine but in real world you usually scale. So far i know, EF migration doesn't handle situation when more migration runs in paralel. Some people, including me, take this sample microservice app as reference, and could easily copy this and later be badly suprised.
Hi Spingee, thanks for your valuable suggestions. You are right, migrations should be a CI/CD step, not a startup task. We also recommend best practice is to run a script as part of CI/CD, apply the migration from the CLI, or build a bundle. We will update the wiki documentation to recommend this, for more details, we suggest visiting the page Applying Migrations - EF Core | Microsoft Docs
Another pattern to consider implementing an init container that can run before app containers are started and apply EF migrations.