Mid From PDF EF Core Entity Framework Core

How to handle transactions across multiple repositories?

  • Use DbContext transaction or IDbContextTransaction:

using var transaction = await

_context.Database.BeginTransactionAsync();

try

// multiple repository operations

await _unitOfWork.CommitAsync();

await transaction.CommitAsync();

catch

await transaction.RollbackAsync();

throw;

More from Entity Framework Core Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details