Devin W.C. Ryan

MySql.Data Reference

I previously wrote a post about configuring MySQL for use with a Microsoft MVC application.  I noticed after publishing that my application could not connect to the database and returned the following exception:

System.ArgumentException: The ADO.NET provider with invariant name ‘MySql.Data.MySqlClient’ is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details. —> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.

In order to solve this I had to do two things:

  1. In the Solution Explore under ‘References’ set Copy Local to true for the reference
  2. Add the database provider configuration to your Web.config as seen below, with your particular version
    <add name="MySQL Data Provider" 
         description=".Net Framework Data Provider for MySQL"  
         type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />

The reason for #2 is that I am trying to run my code on a machine where the provider is not installed, so I have to specify the provider in my configuration file and then installation adds it to the machine.config registering the provider on the remote server.

Leave a Comment

Your email address will not be published. Required fields are marked *