protected RelationalConnection(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] ConnectionStringResolver connectionStringResolver)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(connectionStringResolver, "connectionStringResolver");

            _connectionStringResolver = connectionStringResolver;

            var storeConfig = RelationalOptionsExtension.Extract(configuration);

            if (storeConfig.Connection != null)
            {
                if (!string.IsNullOrWhiteSpace(storeConfig.ConnectionString))
                {
                    throw new InvalidOperationException(Strings.FormatConnectionAndConnectionString());
                }

                _connection      = new LazyRef <DbConnection>(() => storeConfig.Connection);
                _connectionOwned = false;
                _openedCount     = storeConfig.Connection.State == ConnectionState.Open ? 1 : 0;
            }
            else if (!string.IsNullOrWhiteSpace(storeConfig.ConnectionString))
            {
                _connectionString = _connectionStringResolver.Resolve(storeConfig.ConnectionString);
                _connection       = new LazyRef <DbConnection>(CreateDbConnection);
                _connectionOwned  = true;
            }
            else
            {
                throw new InvalidOperationException(Strings.FormatNoConnectionOrConnectionString());
            }
        }
        protected RelationalConnection(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] ConnectionStringResolver connectionStringResolver)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(connectionStringResolver, "connectionStringResolver");

            _connectionStringResolver = connectionStringResolver;

            var storeConfig = RelationalOptionsExtension.Extract(configuration);

            if (storeConfig.Connection != null)
            {
                if (!string.IsNullOrWhiteSpace(storeConfig.ConnectionString))
                {
                    throw new InvalidOperationException(Strings.FormatConnectionAndConnectionString());
                }

                _connection = new LazyRef<DbConnection>(() => storeConfig.Connection);
                _connectionOwned = false;
                _openedCount = storeConfig.Connection.State == ConnectionState.Open ? 1 : 0;
            }
            else if (!string.IsNullOrWhiteSpace(storeConfig.ConnectionString))
            {
                _connectionString = _connectionStringResolver.Resolve(storeConfig.ConnectionString);
                _connection = new LazyRef<DbConnection>(CreateDbConnection);
                _connectionOwned = true;
            }
            else
            {
                throw new InvalidOperationException(Strings.FormatNoConnectionOrConnectionString());
            }
        }