ADO.Net and MySQL Connection

Since there is no out-of-the-box MySQL support, connecting to this popular DMBS might get tricky. Learn how to connect to MySQL using a third-party ADO.Net connector.

A database is a standard when it comes to storing data. Even though there are several popular DataBase Management Systems (DMBSs) to choose from, there are just three big players in the database world; they are Oracle, Microsoft SQL Server and MySQL. According to the latest statistics (2014 Dec), there are huge gaps in popularity between the big players and other solutions like PostgreeSQL, MongoDB or DB2.

Once you decide to rely on the free MySQL, you will discover that there is no out-of-the-box support in .Net and there is no ADO.Net connector for this type of database. Thankfully, there are many third-party solutions available that will allow you to use MySQL the same way as any other supported DBMS.

choose your data connection
                                             Figure 1: MySQL built-in connector missing

Connecting to MySQL

Probably the first step everyone will take is to open the Extension Manager (from the Tools menu in Visual Studio) and search for some proper ADO.Net connector. Once the search is completed, several results will appear and it is only up to you to choose which to install. Even though this process seems straightforward, the problem is that nearly none of these solutions work right after the install. From my personal experience, there is always some "Googling" involved, so it is usually a typical hit or miss. The biggest problem you will encounter is the versions dilema.

entity developer
                                       Figure 2:  third-party solutions via Extension Manager

A better solution

There is a MySQL ADO.Net connector available right from the authors of this popular DMBS. Even though it can't be installed directly from Visual Studio as an extension, everyone can download it for free from the official MySQL website from the following link:

Official MySQL ADO.Net connector

The only thing you need to pay attention to is the version you will install since not all of them are backward/forward compatible. For the sake of this article I will install version 6.6.7 because it works with Visual Studio 2010 that I have currently installed. Also note that these connectors might not work with Express Editions of Visual Studio due to some legal issues.

Downloading and installing the connector

The following process should guide you through the entire installation process.

installing the connector

Installation process

Step 1

Download the appropriate version for our Visual Studio.

Downloading appropriate

Step 2

choose setup type

Step 3

The typical features are all we need.

install MYSQL

Step 4

complet MySQL

Step 5

Finish the installation. After we are done, we need to restart Visual Studio and from then on, we can use the MySQL connecter as any other supported DMBS connector.

MySQL connector
                                    Figure 3: MySQL connector is added and ready to use.

Conclusion

MySQL is one of the most popular DMBSs available, but surprisingly, it is not natively supported by the .Net framework and the ADO.Net connector is missing. Thankfully, there are many third-party connectors available with the official one right from the MySQL authors being one of them.