Entity Framework and transaction isolation level

By default, a Transaction has an IsolationLevel of Serializable. Serializable is the highest level. It requires that the transaction completes before any other transaction is allowed to operate on the data.

It has the following restrictions:

  • Statements cannot read data that has been modified but not yet
    committed by other transactions.
  • No other transactions can modify
    data that has been read by the current transaction until the current
    transaction completes.
  • Other transactions cannot insert new rows with
    key values that would fall in the range of keys read by any
    statements in the current transaction until the current transaction
    completes.

This is a great blog post that explains how to use Transactions with the Entity Framework: Entity Framework transaction scope examples

UPDATE

In Entity Framework 6 the default IsolationLevel is changed to READ_COMMITTED_SNAPSHOT for databases created using Code First, potentially allowing for more scalability and fewer deadlocks. See the future spec of EF 6

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)