Working With Database Transactions In EF Core

preview_player
Показать описание

If you're working with a SQL database, transactions should be an essential component in your toolbox. However, this can easily be obscured if you're working with an ORM. So in this video, I'll show you how to work with transactions in EF Core.

Join my weekly .NET newsletter:

Working With Transaction In EF Core

SQL Server - Transaction Isolation Levels

Read my Blog here:

Subscribe for more:

Chapters
0:00 Setting the scene
1:21 Default transaction behavior in EF Core
1:57 What if you have multiple calls to SaveChanges?
3:05 Defining the method for starting a transaction
4:31 Creating a new transaction with EF Core
5:52 Using transactions in your application
7:57 How transactions work in practice
12:53 Using EF Core's CurrentTransaction implicitly
Рекомендации по теме
Комментарии
Автор

A quick tips: if you use DbTransaction abstract class instead of IDbTransaction interface, you can use async methods.

md.redwanhossain
Автор

Nicely put. I had an idea what transactions are used for and have only ever seen 1-2 implementations of them, but with debugging them in this video I understood them more.

zaharivaklinov
Автор

Thanks Milan! The debugging part is really the cherry on top of an already delicious cake. You are very good at this, I'm proud I found this channel. Your content is gold mate, I'm having a lot of fun =)

cheeseburger
Автор

Great content. Very happy to have discovered your channel. Keep up the good work!

stavrosk.
Автор

Great video Milan! Keep it up with the good work!

pietropivavieira
Автор

Awesome video, way to go! Thanks for bright screen notification )😃

Tolmachovtv
Автор

I like al of your series, I'm in the industry almost for 8 years, I rarely seen people doing videos with good content. Very informative. Keep it up buddy.

anushkashan
Автор

I Appreciate the bright screen warnings lol

nafisrahman
Автор

Thank you! It would be great if you tell more about isolation levels in one of your next video!

alekseis
Автор

Instead of putting rollback into a try/catch you could also implement a Dispose method the calls rollback if the initial BeginTransaction has not been commited yet. So when the transaction goes out of scope without being commited, Roolback ist called automagically. If you'd want nested transactions you can implement a NumberOfOpenTransactions counter

JoeMeyer
Автор

Thanks for a video. Very necessary Topic 🙌

GiorgiChikovani_FromGeorgia
Автор

Great job Milan. I'm not a big fan of EF. Please consider making a video about transactions with Dapper.

davidsantacruz
Автор

Hi Milan can you please make a video on GLOBALIZATION & LOCALIZATION with shared resources in NET CORE 6

zameer.vighio
Автор

Rather than switching to "bright screen" SSMS you can also use the SQL Server tools built into visual studio to run queries and show data. :)

pilotboba
Автор

Great video! Based on what you demonstrated do you need to use rollback if the update won’t execute without the commit being triggered?

icemanja
Автор

If any of the savechanges fail, we would then go to rollback in the catch block?

Thanks for an amazing explanation as always!

milosmilovanovic
Автор

Thanks Milan.. Do you have any DDD course with Dapper?

vidasalud
Автор

Thanks Milan!
My question is regarding "BeginTransaction()" method and it return type.
You are telling at the end, that is possible to return a different type to expose less methods.
Could you give a code example, because i did not understood this point.
Thanks !!!

vasilemoraru
Автор

Hi, Is it common to share transactions between different contexts? Or every context have your transaction life?

welfas
Автор

Very good tutorial👏🏻! I am still wondering how to handle the transaction when dealing with several different data repositories. How to pass a subset of the repositories selected in a given context and validate it at the end?

MrEkwador