Mono/Xamarin (on Mac) + MySQL/PostgreSQL issues...

May 23, 2014 at 7:25 AM
I can use the MySqlConnection class directly just fine:
String params = String.Format("Server={0};Port={1};Database={2};User ID={3};Password={4};", host, port, database, username, password);
mysql = new MySqlConnection(params);
... but loading the same connector/driver using the provider string mechanism to create a DatabaseReader object fails with:
"A System.Configuration.ConfigurationErrorsException was thrown. Failed to find or load the registered .Net Framework Data Provider 'MySql.Data.MySqlClient'."
When I call DbProviderFactories.GetFactoryClasses() to see what's available, MySQL and PostgreSQL are not listed (but, again, both are present and can be used directly just fine in the same project).

Oracle, SQL Server, Sybase, ODBC, and SQLite all show up, but not MySQL/PostgreSQL. It's worth noting that these 2 are the only ones whose references must be added from files. The others are available from the standard list in Xamarin Studio.

It don't think it's a permissions issue since I can use both of those drivers/connectors directly:
switch (type)
{
    case XYZSQLDatabaseType.MySQL:
    {
         String params = String.Format("Server={0};Port={1};Database={2};User ID={3};Password={4};", host, port, database, username, password);
         mysql = new MySqlConnection(params);
         break;
    }
    case XYZSQLDatabaseType.PostgreSQL:
    {
         String params = String.Format("Server={0};Port={1};Database={2};User ID={3};Password={4};", host, port, database, username, password);
         postgresql = new NpgsqlConnection(params);
        break;
    }
    ...
I've tried resetting the provider factories cache and I've tried adding (in addition to mysql.data.dll) mysql.data.entity.dll and mysql.web.dll.

Anything else I can try?
Coordinator
May 23, 2014 at 10:23 AM
There's a workaround :)
The database reader can completely bypass the DbProviderFactories and use a specific provider's factory.

DbProviderFactory factory = MySql.Data.MySqlClient.MySqlClientFactory.Instance;

DatabaseSchemaReader.Utilities.FactoryTools.AddFactory(factory); //static

//use as normal!
Marked as answer by engineering90xi on 5/23/2014 at 1:06 PM
May 23, 2014 at 8:06 PM
That worked great. Thanks a million.

New issue on subsequent call to ReadAll()... Creating a new forum thread, since you answered this one perfectly and completely...