After installation and database setup, you need to add the reference, MySql.Data.dll, in order for your application to connect to MySQL database. In case you are working with Entity Framework, you will also need to add MySql.Data.Entity.dll to your project. You fire up Visual Studio, right-click Add References, select Extensions under Assemblies and type "MySql" in the search box on the top right:
As depicted above, there are several choices for MySql.Data and MySql.Data.Entity. So the question here is which one do you pick? How about picking the latest dll version (6.7.4 version for .NET 4.0 with the path: "C:\Program Files (x86)\MySQL\Connector NET 6.7.4\Assemblies\v4.0\MySql.Data.dll"), the newer the better right?
You may be surprised to find the error below:
You just installed the latest MySQL .NET Connector 6.7.4, added a reference to it, and did not have any reference to version 6.6.5 in your project. So what went wrong? To find the root cause of this problem, you need to dig deep into the machine.config, located in:
x86 - C:\Windows\Microsoft.NET\Framework\[Version]\Config\machine.config
x64 - C:\Windows\Microsoft.NET\Framework64\[Version]\Config\machine.config
When you first install MySQL Server, it comes with MySQL for Visual Studio and registers the the dll v6.6.5.0 in machine.config. Now, to resolve the problem, there are two options to fix it:
If you like this post, please +1 and share it. Also, feel free to leave a comment down below for any questions.
When you first install MySQL Server, it comes with MySQL for Visual Studio and registers the the dll v6.6.5.0 in machine.config. Now, to resolve the problem, there are two options to fix it:
- Go back to Visual Studio and right-click Add References again, but this time, look for the dll version 6.6.5 in the list with the path: "C:\Program Files (x86)\MySQL\MySQL for Visual Studio 1.0.2\Assemblies\v4.0\MySql.Data.dll".
- In case you want to use the latest version 6.7.4, you can always edit the reference in machine.config. (Disclaimer: Be really careful when editing machine.config as it can ruin your application configurations on your machine! Always make a backup of the file before making any changes!)
If you like this post, please +1 and share it. Also, feel free to leave a comment down below for any questions.


