Mid EF Core

How to implement unit of work with EF Core?

public interface IUnitOfWork : IDisposable

IRepository<Customer> Customers { get; }

IRepository<Order> Orders { get; }

Task<int> CommitAsync();

  • Implementation typically injects a single DbContext instance shared across

repositories.

  • CommitAsync() calls DbContext.SaveChangesAsync().

More from Entity Framework Core Tutorial

All questions for this course