Migrations Done Right in .NET
Ғылым және технология
All videos in this playlist: • ASP.NET 8 REST API Tut...
In today's video, we'll see one of the best and simplest ways to manage database schema changes in .NET.
DbUp is a very popular NuGet package that allows you to run your SQL scripts in order, in a single transaction using a fluent API. We'll see how to install it, how to use it and how it can integrate nicely with our existing application
Join us on discord: / amantinband
Get the source code: / amantinband
Support the channel: / amantinband
Connect with me on 'em socials:
Twitter: / amantinband
LinkedIn: / amantinband
GitHub: github.com/amantinband
Check out all my courses on DomeTrain:
dometrain.com/author/amichai-...
Support the channel and get the source code:
/ amantinband
Thanks for watching, don't forget to like & comment & subscribe! ❤️ 💻
Пікірлер: 51
I was looking for something like this ! Very nice and simple thanks a lot ! I was aware depends on docker but I was not aware condition and DbUp package simple to use !
Looks very promising! Will definitely consider it as a replacement for my current EF Core setups :D
I have used dbup (and it's sisters) for years too, but the docker-compose-healthy is cool! Nice takeaway!
Thank you!
Thank you for your effort, Can you talk about profiling the application ?
Thanks Amichai. I love SQL server so much. So, how do I setup my docker compose for it, especially with those comands you specified in the depends_on section?
how do you find this compares to ef core migrations. this seems more straightforward for changes like the one you made in this video, but i wonder if it wouldn't get unwieldy for more involved changes.
Hi @Amichai Mantinband, thanks for the great video! I have one question though, DbUp doesn't seem to support rollback (Down) migrations. Do you think this is a problem?
Nice walkthrough! If you are already using EF, what is the difference between asking EF to run migrations on startup and using DbUp? Seems like the same thing right?
@PeriMCS
Ай бұрын
you should not run migrations at startup on any env other then dev. You run migrations before deployment and they always need to be backwards compatible.
@antonmartyniuk
Ай бұрын
@@PeriMCS in one of my company's products we have a microservices architecture and each service is self-executing migrations on the startup. And for years we never had an issue where we needed to downgrade the database in production because of this approach
@PeriMCS
Ай бұрын
@@antonmartyniuk you don't downgrade db. You should always have db that works with current and previous version of your app.
@PeriMCS
Ай бұрын
@@antonmartyniuk and how you handle it when service doing migration at startup is running in multiple instances?
@antonmartyniuk
Ай бұрын
@@PeriMCS these instances connect to the same database 😉 Whether to use this approach or not - actually it all depends on the requirements and use cases
Very cool. How do you "diff" the old schema of the database with the new schema?
@ajdinhusic2574
26 күн бұрын
this is handled by DbUp, using a database table called SchemaVersions
@DanielOpitz
22 күн бұрын
@@ajdinhusic2574 This table just marks the migrated versions.
@ajdinhusic2574
22 күн бұрын
@@DanielOpitz Right, so what exactly do you mean by "diff" the schemas. And for what purpose?
so, are we introducing a dependency to read embedded resources? :)
What is advantage of this over EF Core Migrations? I didn't hear a single one mentioned in the video. I can think of several disadvantages such as more work to setup, more work to (manually???) create each migration, and less community knowledge/support available. I really don't get why I would want to use this.
@PeriMCS
Ай бұрын
I used this in project many years ago where there wasn't an ORM. Not everyone uses ORM's.
@meetingattender8132
24 күн бұрын
Don't use it unless you like to write raw SQL manually to have more control. If you use an ORM like EF Core stay away from this.
Hey! How do you have this copilot-like terminal autocompletion?
@PeriMCS
Ай бұрын
I think it's just Powershell
How does DbUp compare to EF Core migrations, or why did you choose the first over the latter?
@PeriMCS
Ай бұрын
he is not using EF. Only then it makes sense.
@meetingattender8132
24 күн бұрын
Do not chose this. Use EF Core migrations.
@PeriMCS
24 күн бұрын
@@meetingattender8132 this is not Or. You choose it when you write scripts.
I like your videos Amichai, but don't agree with use of GUID as PK aka ClusterKey in tables.
@pickle1987
Ай бұрын
who cares
but that means it will try to create the tables every time we run the application right? if that is the case I feel something is not right.
@DanielOpitz
Ай бұрын
DbUp tracks the scripts that have already been executed in a table (SchemaVersions).
@meetingattender8132
24 күн бұрын
No it's just like __EFMigrationHistory of EF Core
baldy
@amantinband
Ай бұрын
you misspelled handsome
@SakuraIsayeki
Ай бұрын
@@amantinband Epic answer 🤣🤣🤣
@meetingattender8132
24 күн бұрын
@@amantinband 🤣😂