public ProviderRegistrationsDbContext CreateDbContext()
        {
            var optionsBuilder = new DbContextOptionsBuilder <ProviderRegistrationsDbContext>()
                                 .UseSqlServer(_dbConnection)
                                 .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning));

            if (_environmentService.IsCurrent(DasEnv.LOCAL))
            {
                optionsBuilder.UseLoggerFactory(_loggerFactory);
            }

            var dbContext = new ProviderRegistrationsDbContext(optionsBuilder.Options);

            return(dbContext);
        }
        public ProviderRegistrationsDbContext CreateDbContext()
        {
            var synchronizedStorageSession = _unitOfWorkContext.Find <SynchronizedStorageSession>();
            var sqlStorageSession          = synchronizedStorageSession.GetSqlStorageSession();

            var optionsBuilder = new DbContextOptionsBuilder <ProviderRegistrationsDbContext>()
                                 .UseSqlServer(sqlStorageSession.Connection)
                                 .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning));

            if (_environmentService.IsCurrent(DasEnv.LOCAL))
            {
                optionsBuilder.UseLoggerFactory(_loggerFactory);
            }

            var dbContext = new ProviderRegistrationsDbContext(optionsBuilder.Options);

            dbContext.Database.UseTransaction(sqlStorageSession.Transaction);

            return(dbContext);
        }