public static IServiceCollection AddEntityFramework(this IServiceCollection services, bool configurationIsLocalOrDev, IOptions <ReservationsConfiguration> config)
        {
            return(services.AddScoped(p =>
            {
                var unitOfWorkContext = p.GetService <IUnitOfWorkContext>();
                var azureServiceTokenProvider = new AzureServiceTokenProvider();
                ReservationsDataContext dbContext;
                try
                {
                    var synchronizedStorageSession = unitOfWorkContext.Get <SynchronizedStorageSession>();
                    var sqlStorageSession = synchronizedStorageSession.GetSqlStorageSession();
                    var optionsBuilder = new DbContextOptionsBuilder <ReservationsDataContext>().UseSqlServer(sqlStorageSession.Connection);
                    dbContext = new ReservationsDataContext(sqlStorageSession.Connection, config, optionsBuilder.Options, azureServiceTokenProvider, configurationIsLocalOrDev);
                    dbContext.Database.UseTransaction(sqlStorageSession.Transaction);
                }
                catch (KeyNotFoundException)
                {
                    var connection = AddDatabaseExtension.GetSqlConnection(configurationIsLocalOrDev, config.Value.ConnectionString);
                    var optionsBuilder = new DbContextOptionsBuilder <ReservationsDataContext>().UseSqlServer(connection);
                    dbContext = new ReservationsDataContext(optionsBuilder.Options);
                }

                return dbContext;
            }));
        }
        public StepsBase(TestData testData, TestResults testResults, TestServiceProvider serviceProvider)
        {
            TestData    = testData;
            TestResults = testResults;
            Services    = serviceProvider;
            UserId      = Guid.NewGuid();

            _dbContext = Services.GetService <ReservationsDataContext>();
        }
        public static IServiceCollection AddEntityFramework(this IServiceCollection services)
        {
            return(services.AddScoped(p =>
            {
                var unitOfWorkContext = p.GetService <IUnitOfWorkContext>();
                var synchronizedStorageSession = unitOfWorkContext.Get <SynchronizedStorageSession>();
                var sqlStorageSession = synchronizedStorageSession.GetSqlStorageSession();
                var optionsBuilder = new DbContextOptionsBuilder <ReservationsDataContext>().UseSqlServer(sqlStorageSession.Connection);
                var dbContext = new ReservationsDataContext(optionsBuilder.Options);

                dbContext.Database.UseTransaction(sqlStorageSession.Transaction);

                return dbContext;
            }));
        }