public virtual ConnectionStringResolveResult ResolveConnectionString(string connectionName)
        {
            ConnectionStringResolveResult r = ConnectionStringResolvers.TryResolve(connectionName);

            if (!r.Success)
            {
                throw r.Exception;
            }
            return(r);
        }
        public virtual DatabaseInitializationResult Initialize(string connectionName)
        {
            if (_ignoreConnectionNames.Contains(connectionName))
            {
                DatabaseInitializationResult result = new DatabaseInitializationResult(null, Args.Exception <Exception>("connection explicitly ignored: {0}", connectionName));
                return(result);
            }

            try
            {
                if (string.IsNullOrEmpty(connectionName))
                {
                    throw new ArgumentNullException("connectionName");
                }

                ConnectionStringResolveResult r = ResolveConnectionString(connectionName);

                ConnectionStringSettings conn = r.Settings;

                if (conn == null)
                {
                    throw new InvalidOperationException(string.Format("The connection name ({0}) was not found in the config file", connectionName));
                }

                Type factoryType = ResolveFactoryType(conn);

                DbProviderFactory factory = factoryType.GetField("Instance").GetValue(null) as DbProviderFactory;
                if (factory == null)
                {
                    throw new InvalidOperationException(string.Format("Unable to find Instance field of specified DbProviderFactory ({0})", conn.ProviderName));
                }

                Database database = GetDatabase(conn, factory);

                return(new DatabaseInitializationResult(database));
            }
            catch (Exception ex)
            {
                return(new DatabaseInitializationResult(null, ex));
            }
        }