public TestHedwigContextProvider(bool callBase = true) { var configuration = EnvironmentConfiguration.GetIConfigurationRoot(); var optionsBuilder = new DbContextOptionsBuilder <HedwigContext>() .UseSqlServer(configuration.GetConnectionString("HEDWIG")) .EnableSensitiveDataLogging(); if (TestEnvironmentFlags.ShouldLogSQL()) { var loggerFactory = LoggerFactory.Create(b => b.AddConsole()); optionsBuilder.UseLoggerFactory(loggerFactory); } HttpContextAccessor = new TestHttpContextAccessorProvider().HttpContextAccessor; ContextMock = new Mock <HedwigContext>(optionsBuilder.Options, HttpContextAccessor); ContextMock.CallBase = callBase; ContextMock.Object.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; Context = ContextMock.Object; }