How to fix: cannot obtain provider factory for data provider named mysql.data.mysqlclient

The “cannot obtain provider factory for data provider named mysql.data.mysqlclient” error is a typical MYSQL connection error which you will find in your C# (C-sharp) application. The “cannot obtain provider factory for data provider named mysql.data.mysqlclient” error is created by an incorrect configuration of the MySQL plugin.

It is possible that you have downloaded and installed the wrong version of the MySQL reference. But let’s say that you have downloaded and installed the latest version of the SQL reference.

In the latest version of the SQL Reference you will not find the MySQL data connection. The “cannot obtain provider factory for data provider named mysql.data.mysqlclient” can be fixed by doing the following.

How to fix mysql.data.mysqlclient C sharp error

If you want to fix the “cannot obtain provider factory for data provider named mysql.data.mysqlclient” error you will have to follow these instructions:

  1. Uninstall all the MYSQL plugins via the Windows control panel
  2. Install the latest version of the mysql connector
  3. Ensure that you have the following installed:
    • Data.dll
    • Web.dll
    • Data.Entity.dll
    • Data.Entity.dll
      1. Make sure that they are being copied locally

Add this to your web.config

system.data>
      <DbProviderFactories>
        <clear />
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
        description=".Net Framework Data Provider for MySQL"
        type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, 
        Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
      </DbProviderFactories>
    </system.data>