Deploying an EF Migration Zero Downtime? Watch Out!

  Рет қаралды 7,095

Zoran Horvat

Zoran Horvat

Күн бұрын

Become a patron and get access to source code and exclusive live streams: / deploying-ef-out-81381682
It is fairly easy to deploy an EF migration without stopping the application, unless we made a breaking change. As this video is demonstrating, the migration, which is a DDL script, is normally deployed in a transaction. It is therefore possible to run it alongside online transactions executed by the running application! Again, unless the change imposed by the DDL script will break the application.
In this video, you will learn a safe way to add a field to the model, and so to add a column to the database table, without causing any service interruption that could be noticed by the users. The prior version of the application will be available through the entire process, all until replaced by the new version and stopped.
This update scheme is fully supported by the Entity Framework Core. It only remains that we, developers, make the steps in the right order, and the most daring part of our daily work - deployment - will work out smoothly.
Learn more from video courses:
Beginning Object-oriented Programming with C# ► codinghelmet.c...
Collections and Generics in C# ► codinghelmet.c...
Making Your C# Code More Object-oriented ► codinghelmet.c...
Other courses at Pluralsight ► codinghelmet.c...
Other courses at Udemy ► codinghelmet.c...
Other videos on this channel you may be interested in watching:
Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ► • Using GitHub Copilot t...
Coding with GitHub Copilot - Beginner to Master | VS Code Demo ► • A Comprehensive Guide ...
What is Covariance and Contravariance in C# ► • What is Covariance and...
How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ► • How to Initialize a Cl...
The Null Conundrum: A Guide to Optional Objects in C# ► • How to Avoid Null Refe...
#entityframeworkcore #entityframework #dotnet

Пікірлер: 16
@zoran-horvat
@zoran-horvat Жыл бұрын
Become a patron and get access to source code and exclusive live streams: www.patreon.com/posts/deploying-ef-out-81381682
@mdev3987
@mdev3987 Жыл бұрын
I'm really impressed with this. I'm still scared if the app is maybe not down when im doing migrations :) Had bad expiriances with it. But I'm still a fan of downtime and making backups :D
@amirmirzababapour6016
@amirmirzababapour6016 Жыл бұрын
I really appreciate the video, do you have any thoughts on how such a concept would work if we were to deploy using Kubernetes? How would you run the migration commands in such environment?
@branislavpetrovic7486
@branislavpetrovic7486 2 жыл бұрын
Great video Zoran! How do you approach to DB versioning? Do you use state versioning, transition versioning or hybrid approach? Do you use tools like DbUp, Fluent Migrator or FlyWay to deploy DB changes on production? Could you do the video about DB versioning and deployment? Thanks!
@zoran-horvat
@zoran-horvat 2 жыл бұрын
Actually, due to the nature of my R&D work in recent years, I rarely ever see the database on a project. Hence, I'm not the best guy to talk about migrations - though I do happen to know the theory. My needs nowadays don't go beyond what EF Core is already good at, and so EF Core migrations are just right for me. EF migrations are versioning the schema. I am certain that great deal of components at large, and I mean 98%+ of everything people write, would live happily with that level of control, no matter the toolset.
@jeffersantosss
@jeffersantosss 2 жыл бұрын
The process "Deploy DB changes first and code changes second" only works if the migration is for adding columns or tables. If any columns were removed, renamed, changed type, etc... this could not work as expected.
@zoran-horvat
@zoran-horvat 2 жыл бұрын
Yes, and that is why you don't remove the column. You turn it nullable instead, and stat ignoring it in the application. Removal comes later, in a separate deployment, after it is certain that there is no reason to rollback the application changes. Neither you rename a column, but instead introduce a new nullable column with the new name, then slowly copy the existing content into it before removing the old column in a later release, plus turning the new column non-nullable. It goes the similar path when adding a column with no default, or splitting a column into two, moving to a different table, etc. Zero downtime releases are a mastery, but the reward is great. It pays off manyfold in 24/7 systems where you just don't want your application to ever show a "works on the road" sign or be unresponsive by other means.
@kostasgkoutis8534
@kostasgkoutis8534 2 жыл бұрын
@@zoran-horvat I hope your upcoming videos show all cases you just mentioned here. Great content as always!
@zoran-horvat
@zoran-horvat 2 жыл бұрын
Thanks! And yes, I am already working on the next two episodes, that will cover much more complex deployments than the basic one described here.
@matteopagani813
@matteopagani813 4 ай бұрын
@@zoran-horvat did this video ever come out, we are looking at managing that process exactly and hopefully through a solution like CodeFresh, would love your thoughts on this.
@zoran-horvat
@zoran-horvat 4 ай бұрын
@@matteopagani813 I haven't returned to this topic since. I might in the future because that is an important topic in the development lifecycle.
@ugochukwuumerie6378
@ugochukwuumerie6378 2 жыл бұрын
Great content, new subscriber here 👋. How do you save the generated script, or do you copy and paste for the CICD?
@zoran-horvat
@zoran-horvat 2 жыл бұрын
That depends on the tooling you use. I didn't want to get into those details in this video, because that would be a separate topic,and it does not affect the other operations from this demonstration.
@miroslavgrozdanovski6813
@miroslavgrozdanovski6813 2 жыл бұрын
Nice video, but isn't this just saying "deploy DB changes first and code changes second"? Can you give us some examples where the previous version of the code wouldn't normally work with new DB changes and ways to mitigate that problem?
@zoran-horvat
@zoran-horvat 2 жыл бұрын
The idea of this video is to show the process on a simple case, before a more complex cases come. There are two more videos in preparation, that will develop similar features under more and more stringent conditions. They will build on the principles shown in this video.
@miroslavgrozdanovski6813
@miroslavgrozdanovski6813 2 жыл бұрын
@@zoran-horvat, nice, thank you.
The Fastest Way to Modify a List in C# | Coding Demo
10:30
Zoran Horvat
Рет қаралды 27 М.
ASP.NET Core Full Course For Beginners
3:43:18
Julio Casal
Рет қаралды 585 М.
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН
Почему Катар богатый? #shorts
0:45
Послезавтра
Рет қаралды 2 МЛН
C++ Header Files
15:10
The Cherno
Рет қаралды 750 М.
How to Avoid Null Reference Exceptions: Optional Objects in C#
18:13
EF Core Migrations Deep Dive, Applying Migration, SQL Scripts
16:41
Milan Jovanović
Рет қаралды 19 М.
Testing Entity Framework Core Correctly in .NET
8:03
Nick Chapsas
Рет қаралды 33 М.
Почему я не использую Entity Framework
30:19
Програмысли Влог
Рет қаралды 10 М.
Using Multiple EF Core DbContexts in a Single Application
17:46
Milan Jovanović
Рет қаралды 40 М.
Why Favor Object Composition Over Class Inheritance? A Deep Dive
19:00
The Easiest Way To Manage Database Migrations in .NET
11:40
Nick Chapsas
Рет қаралды 42 М.
EF Core Performance Optimization Challenge | 233x FASTER
14:42
Milan Jovanović
Рет қаралды 71 М.