C
C#2w ago
Clean Cock

✅ EF Core migrations with Docker

I'm trying to do a simple blazor app that works with database but I can't find a standardized good practice to perform migrations. I'm running both db and blazor app via docker compose.
17 Replies
Scratch
Scratch2w ago
Migrations Overview - EF Core
Overview of using migrations to manage database schemas with Entity Framework Core
jcotton42
jcotton422w ago
Applying Migrations - EF Core
Strategies for applying schema migrations to production and development databases using Entity Framework Core
Clean Cock
Clean CockOP2w ago
Yea, the catch is that im running both database and blazor app via docker compose on separate containers
Sossenbinder
Sossenbinder2w ago
Anything wrong with running migrations on startup? If you're on compose, you (probably) run only a single instance anyways, unless you use replicas You could also build a startup dependency chain and run an init container after your db container is up and running
Mayor McCheese
How is that a catch?
Clean Cock
Clean CockOP2w ago
im fairly new to both docker and ef core and I mostly have no idea what are you talking about sorry, ill try to do a better research first
jcotton42
jcotton422w ago
Am I correct in that this is a two-container setup? One for you app, the other for the database server?
Clean Cock
Clean CockOP2w ago
yes
jcotton42
jcotton422w ago
Applying Migrations - EF Core
Strategies for applying schema migrations to production and development databases using Entity Framework Core
jcotton42
jcotton422w ago
Do you just want it done automatically when the app starts up, or do you want to do it in a separate step?
Clean Cock
Clean CockOP2w ago
im just starting to develop this app so for now it would be every time I add a new model or something if I do not change anything in schema and set migrations on startup will it create empty migrations?
jcotton42
jcotton422w ago
It only applies the migrations that aren't already applied to the database. You probably want "Apply migrations at runtime"
Clean Cock
Clean CockOP2w ago
oh, so for development applying them on startup would be the best option
jcotton42
jcotton422w ago
Yes. For production, you may want to consider other options, all depends on your needs. Personally for my personal apps I just migrate at startup.
Clean Cock
Clean CockOP2w ago
yea this makes life easier, ill read about that and implement it later, thanks
jcotton42
jcotton422w ago
$close
MODiX
MODiX2w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?