[mysql] How to connect to a MySQL Data Source in Visual Studio

I use the MySQL Connector/Net to connect to my database by referencing the assembly (MySql.Data.dll) and passing in a connection string to MySqlConnection. I like that because I don't have to install anything.

Is there some way to "Choose Data Source" in Visual Studio 2010 without installing something?

How can I get a MySQL option (localhost) to show up on one of these lists? Or do I have to install something?

(I don't want to use ODBC btw)

"Add Connection" from Server Explorer: alt text

Entity Data Model Wizard: alt text

This question is related to mysql visual-studio-2010 datasource mysql-connector

The answer is


After a lot of searching and trying many solutions, I got it finally:

  1. uninstall connector

  2. uninstall MySQL for Visual Studio from control panel

    click here

  3. reinstall them according to the table below

    click here

  4. copy the assembly files from C:\Program Files (x86)\MySQL\MySQL Connector Net 6.9.8\Assemblies\v4.5 to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE

  5. log off and reopen your solution

  6. enjoy


Installing the following packages:

adds MySQL Database to the data sources list (Visual Studio 2017)


Right Click the Project in Solution Explorer and click Manage NuGet Packages

Search for MySql.Data package, when you find it click on Install

Here is the sample controller which connects to MySql database using the mysql package. We mainly make use of MySqlConnection connection object.

 public class HomeController : Controller
{
    public ActionResult Index()
    {
        List<employeemodel> employees = new List<employeemodel>();
        string constr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
        using (MySqlConnection con = new MySqlConnection(constr))
        {
            string query = "SELECT EmployeeId, Name, Country FROM Employees";
            using (MySqlCommand cmd = new MySqlCommand(query))
            {
                cmd.Connection = con;
               con.Open();
                using (MySqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        employees.Add(new EmployeeModel
                        {
                            EmployeeId = Convert.ToInt32(sdr["EmployeeId"]),
                            Name = sdr["Name"].ToString(),
                            Country = sdr["Country"].ToString()
                        });
                    }
                }
                con.Close();
            }
        }

        return View(employees);
    }
}

This seems to be a common problem. I had to uninstall the latest Connector/NET driver (6.7.4) and install an older version (6.6.5) for it to work. Others report 6.6.6 working for them.

See other topic with more info: MySQL Data Source not appearing in Visual Studio


View ImageI have got the same problem for my vs 2013 on 64-bit machine. So i tried to download MySql extension for VS and install it on my machine. and restart the vs.


  1. Download MySQL Connector .NET (6.9.4 on this date) from here and install it CUSTOM!
  2. Remove the ASP.NET WEB providers option or the installer will write in machine.config!
  3. Download MySQL for Visual Studio from here and install it CUSTOM. Be sure to check the integration options. You need this step because after Connector .NET 6.7 the installer will no longer integrate the connector with Visual Studio. This installer can take longer then expected. This is it.

You can install it from alternate download here which should have integrated with VS correctly but it did not and I got a strange error and after the reinstall it is ok.


"Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration. That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows."

Source: http://dev.mysql.com/downloads/connector/net/6.6.html


unfortunately this is not supported in the builtin tools in visual studio. however, you can create your own data provider using mysql connector but still have to integrate it from code


install the MySQL .NET Connector found here http://dev.mysql.com/downloads/connector/net/

alt text


In order to get the MySQL Database item in the Choose Data Source window, one should install the MySQL for Visual Studio package available here (the last version today is 1.2.6):

https://dev.mysql.com/downloads/windows/visualstudio/


Examples related to mysql

Implement specialization in ER diagram How to post query parameters with Axios? PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver' phpMyAdmin - Error > Incorrect format parameter? Authentication plugin 'caching_sha2_password' is not supported How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Connection Java-MySql : Public Key Retrieval is not allowed How to grant all privileges to root user in MySQL 8.0 MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

Examples related to visual-studio-2010

variable is not declared it may be inaccessible due to its protection level SSIS Excel Connection Manager failed to Connect to the Source This project references NuGet package(s) that are missing on this computer Gridview get Checkbox.Checked value error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj What is the difference between Visual Studio Express 2013 for Windows and Visual Studio Express 2013 for Windows Desktop? Attach (open) mdf file database with SQL Server Management Studio What is and how to fix System.TypeInitializationException error? Could not load file or assembly "Oracle.DataAccess" or one of its dependencies IIS error, Unable to start debugging on the webserver

Examples related to datasource

Spring Boot Configure and Use Two DataSources Configure DataSource programmatically in Spring Boot Unable to find the requested .Net Framework Data Provider in Visual Studio 2010 Professional How to use JNDI DataSource provided by Tomcat in Spring? Using a list as a data source for DataGridView Binding Combobox Using Dictionary as the Datasource How to connect to a MySQL Data Source in Visual Studio VB.NET: Clear DataGridView c# dictionary one key many values How do I manually configure a DataSource in Java?

Examples related to mysql-connector

How to install mysql-connector via pip How to connect to MySQL Database? java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse mysql.h file can't be found MySql with JAVA error. The last packet sent successfully to the server was 0 milliseconds ago How to connect to a MySQL Data Source in Visual Studio