Chapter 4. Transactions and Concurrency Control

In this chapter, we will cover the following topics:

  • Using explicit transactions
  • Using transactions in custom SQL operations
  • Implementing optimistic concurrency in SQL Server
  • Implementing optimistic concurrency in a database-agnostic way

Introduction

In this chapter, we will see how Entity Framework Core deals with concurrency, that is, multiple simultaneous (or almost) changes to the same database object. In particular, we will see the two most common ways to handle concurrency: optimistic concurrency control and pessimistic concurrency control, also known as transactions.

Get Entity Framework Core Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.