Due to performance in our system (deadlocks, db reads are locked when db writes are in progress, etc) we want to try out snapshop isolation. I have read about snapshot isolation level, here. We use Entity Framework
I have set Snapshop isolation on the db and want to configure our web api apps to use this isolation for both reads and writes. How can I do this? I have read that this can be done in web.config but cannot find how..
According to the Entity Framework documentation, you need to use a transaction to set the isolation level:
using (var tx = myContext.Database.BeginTransaction(IsolationLevel.Snapshot)) {
// Perform operations on the context...
await myContext.SaveAsync();
tx.Commit();
}
See also this answer for details on the defaults: essentially EF uses whatever the database has as its default transaction isolation level via IsolationLevel.Unspecified
.