37

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

JohnB
  • 15,593
  • 15
  • 91
  • 109

11 Answers11

35

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

alt text

Jon Black
  • 15,289
  • 5
  • 40
  • 41
  • Thanks, but I am familiar with the link to that driver! – JohnB Nov 20 '10 at 23:58
  • @JohnB then what's the problem? f00's screenshot shows that MySql appears as an option in the "Choose Data Source" dialog. – Lucas Nov 21 '10 at 00:16
  • @Lucas, no I get that, my question was whether is was possible to Add a Connection through the Server Explorer by just using the `MySql.Data.dll` assembly. @f00: +1 for your help. – JohnB Nov 22 '10 at 16:53
  • @JohnB Oops, I misread, though you meant it didn't show up for you. I'll add an answer with details, for future reference :) and +1 f00 – Lucas Nov 23 '10 at 14:48
  • See my post below - it seems you may need to install older drivers for VS2010!! – stuzor Feb 07 '14 at 22:57
  • I did the same, along with the standalone installer for VS (https://dev.mysql.com/downloads/windows/visualstudio/), restart Visual Studio 2017 and there were the driver ready to use. It did not appear on VS2019, though. – Chesare Aug 26 '19 at 10:14
27

"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

Memet Olsen
  • 4,438
  • 5
  • 36
  • 49
11

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

Community
  • 1
  • 1
Sulyman
  • 340
  • 3
  • 12
8

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

Community
  • 1
  • 1
stuzor
  • 1,846
  • 1
  • 24
  • 33
  • 2
    Had a similar experience. MySQL wouldn't show in the Data Sources list using Connector/NET 6.7.4. Version 6.6.5 was fine though. – mkataja Aug 19 '13 at 09:15
  • THANK YOU MKATAJA AND SERGIO!!!!!!! Uninstalling my current MySQL Connector from Control Panel, installing 6.6.6, relaunching VS worked perfectly! Thank you!! – Subby Dec 22 '13 at 21:10
  • 2
    Starting version 6.7, Visual Studio integration was splitted into a different product, MySql for Visual Studio, see http://dev.mysql.com/downloads/windows/visualstudio/ – Fernando Gonzalez Sanchez Jul 15 '14 at 01:39
  • Thanks! I installed the most recent version of SqlConnector and it didn't work for VS2010. Installed 6.6.6, and success! – KidBilly Sep 03 '14 at 18:48
8
  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.

Ognyan Dimitrov
  • 5,392
  • 1
  • 40
  • 64
7

Visual Studio requires that DDEX Providers (Data Designer Extensibility) be registered by adding certain entries in the Windows Registry during installation (HKLM\SOFTWARE\Microsoft\VisualStudio\{version}\DataProviders) . See DDEX Provider Registration in MSDN for more details.

Lucas
  • 16,575
  • 5
  • 43
  • 40
4

Installing the following packages:

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

j.xavier.atero
  • 334
  • 1
  • 6
  • 17
2

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

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/

Jordan
  • 477
  • 6
  • 15
1

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);
    }
}
Jeff D
  • 319
  • 3
  • 4
0

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

Ali Tarhini
  • 5,078
  • 6
  • 38
  • 63
  • Any examples on how to use my own data provider to create ASP.NET Reports? All the examples I have seen use the built in wizards/tools. – JohnB Nov 22 '10 at 16:54