Bug #88660 this version create a bad dbfacty and null DbDataAdapter on C# when create it
Submitted: 26 Nov 2017 22:29 Modified: 5 Apr 2019 15:11
Reporter: Ehab Tharwat Offroad Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.10.4 OS:Windows (All Versions)
Assigned to: CPU Architecture:Any

[26 Nov 2017 22:29] Ehab Tharwat Offroad
in C# when try to make dbdata adapter with this version of mysql.net version the factory is created not complete and it return null dbdata adapter in time its working with the 6.9.9 version

How to repeat:
just initiate this command in C# to create a data adapter

DbDataAdapter dbdAdapter = dbFactory.CreateDataAdapter();
dbdAdapter.SelectCommand = Command.Create(sSellectString, null, DBConn);
[27 Nov 2017 12:10] Chiranjeevi Battula
Hello !!,

Thank you for the bug report.
Could you please provide repeatable test case (exact steps/sample project, connection string,create tables statements etc. - please make it as private if you prefer) to confirm this issue at our end?

[28 Nov 2017 8:08] Ehab Tharwat Offroad
Code is in several procedures so i will try to collect the important parts

connectoin string
ProviderName = "MySql.Data.MySqlClient";
sConnectingString = "Server=" + sServerName + ";Database= " + sDataBaseName + "; sUserName + "; Pwd=" + sPassword + "; Connect Timeout = 60; Command Timeout  = 200; "+                                                    "CharSet=utf8; "Workstation ID=" + Environment.MachineName + "; tablecache = true; " + "CacheServerProperties = True; " + "UseCompression=True; " + "Pooling=True;" +

ProviderName = "System.Data.SqlClient";
dbFactory = DbProviderFactories.GetFactory(ProviderName);      ----- > This line with the Mysql.Net Ver 6.10.4 create a bad fault (dbFactory)

DbDataAdapter dbdAdapter = dbFactory.CreateDataAdapter();        ----- > This line Create a null db data adapter
dbdAdapter.SelectCommand = Command.Create(sSellectString, null, DBConn);         --------- when you try to assign the select string to the adapter it generate error because the dbdAdapter is null

PS: i don't know why the post don't show my real name
[20 Dec 2017 6:13] Chiranjeevi Battula
Hello Ehab,

Thank you for the feedback.
Verified based on internal discussion with dev's.

[23 Jan 2018 21:33] Sean Nolan
This is marked as non-critical but if you use it then it is absolutely critical and makes the 6.10 release unusable.
[30 Jan 2018 7:24] Kevin Port

are there any news since [20 Dec 2017 6:13]?

In our opinion it's a critical bug!!!!
[31 Jan 2018 20:58] robert mcbean
simple test with NUnit. Both DbCommandBuilder and DbDataAdapter are returned as null

        public void TestCreateFactory()
            ConnectionStringSettings connectionStringSettings =


            DbProviderFactory factory = DbProviderFactories.GetFactory(connectionStringSettings.ProviderName);
            DbCommandBuilder builder = factory.CreateCommandBuilder();

            DbDataAdapter adapter = factory.CreateDataAdapter();
[18 Feb 2018 12:53] Ehab Tharwat Offroad
Its critical for me and i can't use this version any more.
[26 Feb 2018 13:18] Toras Nithou
I am also affected by this problem, so I checked the source code.

The cause of the problem is simple, the CreateDataAdapter() method has been deleted.
(It seems to be the effect of correspondence to .NET Standard.)

I think how to deal with it is simple.
For example, I think that you can restore the method in a way that it can also support .NET Standard as follows.

    public override DbDataAdapter CreateDataAdapter()
      return new MySqlDataAdapter();

Also, I think the CreateCommandBuilder method and the CanCreateDataSourceEnumerator property are in the same state.
Please check this information and if you do not have a problem, I would like you to deal with it.

# This depends on translation tools. I am sorry if there are strange sentences.
[21 Mar 2018 6:56] Ehab Tharwat Offroad
After trying several things regrading your suggestion which is not a solution, also the CreateDataAdapter you mentioned didn't deleted from the factory library as you said as it still exist and don't make error when you use it, but I think i discover the bug in the MYSQL Connector Net exactly now. 

The Problem is in the new MYSQL connector Net driver with the DbProviderFactory livrary in DotNet framework that enable you to make a data layer and work with it whatever the database you are working with.

There is something happen in the new MYSQL driver don't let the DbProviderFactory work correctly and return a corrupted DB provider factory that can't create a database adapter, so it create a null database adapter.

for that it let me check if the driver used in the application is mysql so i make a special configuraiton line to create mysql adapter if its other than mysql ,,, it will create it automatically with the corresponding driver.

That is very terrible upgrade to the MYSQL Connector Net that remove or corrupted functionality with the DbProviderFactory as they upgrade to the past not for adding new future ... really very disappointing
[25 Mar 2018 9:36] Toras Nithou
That's right. This is a bug in MySQL Connector/Net.
My comment is to the developer of Connector.

Since the method does not exist in the MySqlClientFactory class of Connector,
the method of the base class not overridden returns null.
# It is in the source of Connector .\MySQL.Data\src\MySqlClientFactory.cs file.

If we need a workaround on the Connector user side,
there is a way to create your own factory as a temporary workaround.
For example,

Since myself does not necessarily require MySQL, wait patiently for bug fixes.

# This depends on translation tools. I am sorry if there are strange sentences.
[27 Mar 2018 9:44] Ehab Tharwat Offroad
Thanks for your help and followup Toras and will be waiting for the bug fix in the next version
[26 Apr 2018 5:54] gao haidong
        /// <summary>
        /// Returns a strongly typed <see cref="DbDataAdapter"/> instance. 
        /// </summary>
        /// <returns>A new strongly typed instance of <b>DbDataAdapter</b>. </returns>
        public override DbDataAdapter CreateDataAdapter()
            return new MySqlDataAdapter();
        /// <summary>
        /// Returns a strongly typed <see cref="DbCommandBuilder"/> instance. 
        /// </summary>
        /// <returns>A new strongly typed instance of <b>DbCommandBuilder</b>.</returns>
        public override DbCommandBuilder CreateCommandBuilder()
            return new MySqlCommandBuilder();

        /// <summary>
        /// Returns true if a <b>MySqlDataSourceEnumerator</b> can be created; 
        /// otherwise false. 
        /// </summary>
        public override bool CanCreateDataSourceEnumerator
            get { return false; }
[26 Apr 2018 6:55] gao haidong
dbfacty and null DbDataAdapter on C# when create it

Attachment: EnterpriseLibrary.Test.MySql.rar (application/octet-stream, text), 210.31 KiB.

[26 Apr 2018 6:57] gao haidong
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System;
using System.Data;
using System.Data.Common;

namespace EnterpriseLibrary.Test.MySql
    class Program
        static void Main(string[] args)

        private static void TestMySql()
            const string sqlCmd = @"select * from  City ";

            DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection), false);
            Database db = DatabaseFactory.CreateDatabase("BizDbMySql");

            using (DbCommand cmd = db.GetSqlStringCommand(sqlCmd))
                catch (Exception ex)
[26 Apr 2018 11:00] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=90589 marked as duplicate of this one.
[26 Apr 2018 15:55] Bradley Grainger
If you're affected by this, as a workaround you could switch to https://github.com/mysql-net/MySqlConnector which is API-compatible with Connector/NET but not affected by this bug.
[30 Apr 2018 12:12] gao haidong
Why such a bug can't be solved for so long? Why can't the third party solve the problem?  https://github.com/mysql-net/MySqlConnector/


Fixed Bugs
The following bugs in Connector/NET are fixed by switching to MySqlConnector.

#37283, #70587: Distributed transactions are not supported
#50773: Can’t use multiple connections within one TransactionScope
#61477: ColumnOrdinal in schema table is 1-based
#66476: Connection pool uses queue instead of stack
#70111: Async methods execute synchronously
#70686: TIME(3) and TIME(6) fields serialize milliseconds incorrectly
#72494, #83330: EndOfStreamException inserting large blob with UseCompression=True
#73610: Invalid password exception has wrong number
#73788: Can’t use DateTimeOffset
#75604: Crash after 29.4 days of uptime
#75917, #76597, #77691, #78650, #78919, #80921, #82136: “Reading from the stream has failed” when connecting to a server
#77421: Connection is not reset when pulled from the connection pool
#78426: Unknown database exception has wrong number
#78760: Error when using tabs and newlines in SQL statements
#78917, #79196, #82292, #89040: TINYINT(1) values start being returned as sbyte after NULL
#80030: Slow to connect with pooling disabled
#81650, #88962: Server connection string option may now contain multiple, comma separated hosts that will be tried in order until a connection succeeds
#83229: “Unknown command” exception inserting large blob with UseCompression=True
#84220: Cannot call a stored procedure with . in its name
#84701: Can’t create a parameter using a 64-bit enum with a value greater than int.MaxValue
#85185: ConnectionReset=True does not preserve connection charset
#86263: Transaction isolation level affects all transactions in session
#87307: NextResult hangs instead of timing out
#87316: MySqlCommand.CommandTimeout can be set to a negative value
#87868: ColumnSize in schema table is incorrect for CHAR(36) and BLOB columns
#87876: IsLong is schema table is incorrect for LONGTEXT and LONGBLOB columns
#88058: decimal(n, 0) has wrong NumericPrecision
#88124: CommandTimeout isn’t reset when calling Read/NextResult
#88611: MySqlCommand can be executed even if it has “wrong” transaction
#88660: MySqlClientFactory.Instance.CreateDataAdapter() and CreateCommandBuilder return null
#89085: MySqlConnection.Database not updated after USE database;
#89159: MySqlDataReader cannot outlive MySqlCommand
#89335: MySqlCommandBuilder.DeriveParameters fails for JSON type
[9 May 2018 15:45] Ehab Tharwat Offroad
Yes you can switch to MySqlConnector, but this workaround lose the one the benefit from using DbProviderFactory that return a correct db provider factory which let me use what ever database i want with my code , and by this solution it restrict me to only use the MySqlConnector and loose my application the power of switching to any database.. that is very disappointing and let me restrict to the old version of MySQL Connector/Net
[16 May 2018 14:44] Renato Pisani
I had the Problem with the DbDataAdapter. But it was happening only on the Customer that uses our application. In our development and test environment, we didn't have any problem. 
After a few hours, I found out that the new Connector (version 8.0.11) was installed on the computer that had problems with the DataAdapter. I removed this Connector and installed the 6.9.9 and the problem was gone.
[15 Jul 2018 16:15] Anderson Santos
it's fixed this MySQL Connector ?
I have the same issues in my code when i try to create dataadaper returns null.

 DbProviderFactory factory = DbProviderFactories.GetFactory(strProviderName);
 DbDataAdapter da = factory.CreateDataAdapter(); //Here returns null for adapter and i get error in the next line when i try use dataadapter

  RetAdp.SelectCommand = Cmd; // here is where the error happen

  Anyone solved this, have another sugestions?
[30 Aug 2018 9:20] Simon Sprott
How is this 'Non-Critial' it basically makes it impossible to use MySQL via the DbProviderFactory interface, so any applications connecting to it in a generic way are knackered...
[22 Feb 2019 23:18] Bradley Grainger
Looks like this will be fixed in 6.10.9; see bug #92206 and https://github.com/mysql/mysql-connector-net/commit/1f35b4338508413afaed7b4b5a733e405aada4...
[5 Apr 2019 15:11] Christine Cole
Posted by developer:
Fixed as of the upcoming MySQL Connector/NET 8.0.13 and 6.10.9 release, and here's the changelog entry:

The implementation of DbProviderFactory prevented an application from
connecting to MySQL in a generic way. Now, invoking the CreateDataAdapter
method returns a valid adapter instead of returning the null value.

Thank you for the bug report.