private static void Initialize(bool applyEFHack, bool supportExplicitConnectionStrings)
        {
            if (supportExplicitConnectionStrings && (applyEFHack || IsEF41HackRequired()))
            {
                EFProviderUtilities.UseEF41Hack();
            }

            InitializeDbProviderFactories();
        }
        private static void InitializeDbProviderFactories()
        {
            try
            {
                // ensure all the factories are loaded
                DbProviderFactories.GetFactoryClasses();
            }
            catch (ArgumentException)
            {
            }

            Type type = typeof(DbProviderFactories);

            DataTable table;
            object    setOrTable = (type.GetField("_configTable", BindingFlags.NonPublic | BindingFlags.Static) ??
                                    type.GetField("_providerTable", BindingFlags.NonPublic | BindingFlags.Static)).GetValue(null);

            if (setOrTable is DataSet)
            {
                table = ((DataSet)setOrTable).Tables["DbProviderFactories"];
            }

            table = (DataTable)setOrTable;

            foreach (DataRow row in table.Rows.Cast <DataRow>().ToList())
            {
                DbProviderFactory factory;
                try
                {
                    factory = DbProviderFactories.GetFactory(row);
                }
                catch (Exception)
                {
                    continue;
                }

                var profType = EFProviderUtilities.ResolveFactoryType(factory.GetType());
                if (profType != null)
                {
                    DataRow profiled = table.NewRow();
                    profiled["Name"]                  = row["Name"];
                    profiled["Description"]           = row["Description"];
                    profiled["InvariantName"]         = row["InvariantName"];
                    profiled["AssemblyQualifiedName"] = profType.AssemblyQualifiedName;
                    table.Rows.Remove(row);
                    table.Rows.Add(profiled);
                }
            }
        }