Skip to content

Instantly share code, notes, and snippets.

View 1saeedsalehi's full-sized avatar

Saeed Salehi 1saeedsalehi

View GitHub Profile
@bdebaere
bdebaere / MyDbContext.cs
Last active June 26, 2023 15:13
Apply WITH(NOLOCK) to every table in EntityFrameworkCore 3.x
public class MyDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(connectionString);
optionsBuilder.ReplaceService<IQuerySqlGeneratorFactory, WithNolockQuerySqlGeneratorFactory>();
base.OnConfiguring(optionsBuilder);
}