I am using Entity Framework 6 in an MVC 5 project. As you\'re aware of, SELECT queries in SQL Server perform faster and more efficient if we use WITH (NOL
In our project we use combination of the second and third solutions, suggested by @Cem Mutlu and @anotherNeo.
Experiment with Sql Profiler showed that we have to use pair of commands:
because NET reuse connections via SqlConnectionPool
internal class NoLockInterceptor : DbCommandInterceptor
{
public static readonly string SET_READ_UNCOMMITED = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED";
public static readonly string SET_READ_COMMITED = "SET TRANSACTION ISOLATION LEVEL READ COMMITTED";
public override void ScalarExecuting(DbCommand command, DbCommandInterceptionContext