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

  • @emiraksoy1520
    @emiraksoy1520Ай бұрын

    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 !

  • @SakuraIsayeki
    @SakuraIsayekiАй бұрын

    Looks very promising! Will definitely consider it as a replacement for my current EF Core setups :D

  • @andersjuul8310
    @andersjuul8310Ай бұрын

    I have used dbup (and it's sisters) for years too, but the docker-compose-healthy is cool! Nice takeaway!

  • @ArturoNull
    @ArturoNullАй бұрын

    Thank you!

  • @ahmadalsader1047
    @ahmadalsader1047Ай бұрын

    Thank you for your effort, Can you talk about profiling the application ?

  • @Aweklin
    @AweklinАй бұрын

    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?

  • @erikgrundy
    @erikgrundyАй бұрын

    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.

  • @ajdinhusic2574
    @ajdinhusic257426 күн бұрын

    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?

  • @soucianceeqdamrashti8175
    @soucianceeqdamrashti8175Ай бұрын

    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

    @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

    @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

    @PeriMCS

    Ай бұрын

    @@antonmartyniuk you don't downgrade db. You should always have db that works with current and previous version of your app.

  • @PeriMCS

    @PeriMCS

    Ай бұрын

    @@antonmartyniuk and how you handle it when service doing migration at startup is running in multiple instances?

  • @antonmartyniuk

    @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

  • @DanielOpitz
    @DanielOpitzАй бұрын

    Very cool. How do you "diff" the old schema of the database with the new schema?

  • @ajdinhusic2574

    @ajdinhusic2574

    26 күн бұрын

    this is handled by DbUp, using a database table called SchemaVersions

  • @DanielOpitz

    @DanielOpitz

    22 күн бұрын

    @@ajdinhusic2574 This table just marks the migrated versions.

  • @ajdinhusic2574

    @ajdinhusic2574

    22 күн бұрын

    @@DanielOpitz Right, so what exactly do you mean by "diff" the schemas. And for what purpose?

  • @alcoholrelated4529
    @alcoholrelated452925 күн бұрын

    so, are we introducing a dependency to read embedded resources? :)

  • @RandallEike
    @RandallEikeАй бұрын

    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

    @PeriMCS

    Ай бұрын

    I used this in project many years ago where there wasn't an ORM. Not everyone uses ORM's.

  • @meetingattender8132

    @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.

  • @evilsquirr3l882
    @evilsquirr3l882Ай бұрын

    Hey! How do you have this copilot-like terminal autocompletion?

  • @PeriMCS

    @PeriMCS

    Ай бұрын

    I think it's just Powershell

  • @krccmsitp2884
    @krccmsitp2884Ай бұрын

    How does DbUp compare to EF Core migrations, or why did you choose the first over the latter?

  • @PeriMCS

    @PeriMCS

    Ай бұрын

    he is not using EF. Only then it makes sense.

  • @meetingattender8132

    @meetingattender8132

    24 күн бұрын

    Do not chose this. Use EF Core migrations.

  • @PeriMCS

    @PeriMCS

    24 күн бұрын

    @@meetingattender8132 this is not Or. You choose it when you write scripts.

  • @michaelkopljan578
    @michaelkopljan578Ай бұрын

    I like your videos Amichai, but don't agree with use of GUID as PK aka ClusterKey in tables.

  • @pickle1987

    @pickle1987

    Ай бұрын

    who cares

  • @DaminGamerMC
    @DaminGamerMCАй бұрын

    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

    @DanielOpitz

    Ай бұрын

    DbUp tracks the scripts that have already been executed in a table (SchemaVersions).

  • @meetingattender8132

    @meetingattender8132

    24 күн бұрын

    No it's just like __EFMigrationHistory of EF Core

  • @BeyondLegendary
    @BeyondLegendaryАй бұрын

    baldy

  • @amantinband

    @amantinband

    Ай бұрын

    you misspelled handsome

  • @SakuraIsayeki

    @SakuraIsayeki

    Ай бұрын

    @@amantinband Epic answer 🤣🤣🤣

  • @meetingattender8132

    @meetingattender8132

    24 күн бұрын

    @@amantinband 🤣😂

Келесі