public ProviderCommitmentsDbContext CreateDbContext() { var optionsBuilder = new DbContextOptionsBuilder <ProviderCommitmentsDbContext>() .UseSqlServer(_dbConnection) .UseLoggerFactory(_loggerFactory) .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning)); var dbContext = new ProviderCommitmentsDbContext(optionsBuilder.Options); return(dbContext); }
public ProviderCommitmentsDbContext CreateDbContext() { var synchronizedStorageSession = _unitOfWorkContext.Find <SynchronizedStorageSession>(); var sqlStorageSession = synchronizedStorageSession.GetSqlStorageSession(); var optionsBuilder = new DbContextOptionsBuilder <ProviderCommitmentsDbContext>() .UseSqlServer(sqlStorageSession.Connection) .UseLoggerFactory(_loggerFactory) .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning)); var dbContext = new ProviderCommitmentsDbContext(optionsBuilder.Options); dbContext.Database.UseTransaction(sqlStorageSession.Transaction); return(dbContext); }