Bug #59120 The MySQL Connector/Net Driver Is Not Registered in Visual Studio 2010 (Release)
Submitted: 23 Dec 2010 2:16 Modified: 24 Dec 2010 5:24
Reporter: David Hanson Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.3.5 OS:Windows (Windows 7 64-Bit)
Assigned to: CPU Architecture:Any
Tags: Driver Not Registered, Entity Framework 4.0, MySQL Connector/Net, visual studio 2010, Windows 7 64-bit

[23 Dec 2010 2:16] David Hanson
Description:
After installing the MySQL Connector/Net on my Windows 7 64-bit machine with Visual Studio 2010 (release version) the MySQL driver is not registered with Visual Studio.

There are two separate issues here:

1) When using the Entity Framework 4.0, the MySQL driver is not even shown as an option when adding a new database connection to an Entity Model.

and,

2) When adding a regular ADO.NET Data Connection using Server Explorer, the MySQL driver is shown however when I attempt to type information into the "Server name" textbox an error is raised that says "Object reference not set to an instance of an object".  

I would really like to considering using MySQL as an alternative to the MS SQL Server solutions we develop.  I hope we can get this issue resolved quickly so that we can progress with our evaluation.

I would appreciate any guidance you can provide.

Thank you.

How to repeat:
Setup the following environment:

- Windows 7 64-Bit
- Microsoft Visual Studio 2010
- Install two MySQL servers on the same computer:
      - MySQL Server 5.1 (port: 3306)
      - MySQL Server 5.5 (port: 3307)
- Install MySQL Connector/Net 6.3.5
- Run Visual Studio 2010
- Create a new project (ASP.NET WebForms)
- Use Server Explorer to add a new database connection
- Attempt to add a database connection to a new Entity Data Model

Suggested fix:
Register the driver for MySQL Connector/Net 6.3.5 with Visual Studio 2010.
[23 Dec 2010 10:40] Bogdan Degtyariov
Hi David,

Can you please be more specific on the exact steps I must follow to repeat the problem. So far I have not succeeded in it.

 - created a new "ASP.NET Web Application" project

 - added a new connection in the server explorer

 - added a new data model as follows:
   Project -> Add New Item -> Visual C# -> Data -> ADO.NET Entity Data Model

 - I do not completely understand what did you mean saying
   "Attempt to add a database connection to a new Entity Data Model",
   so I opened Model1.edmx in the design mode Right Mouse Click ->
   Update Model From Database -> Add tab -> Checked tables in the database ->
   Finish. Everything worked fine. Uploading screenshot in the next post.
[23 Dec 2010 10:42] Bogdan Degtyariov
Screenshot with tables

Attachment: vs_entity_net.jpg (image/jpeg, text), 165.62 KiB.

[23 Dec 2010 19:56] David Hanson
Hi Bogdan,

Thank you for your quick response.

When I attempt to configure the connection for the entity data model there is no MySQL Connector/NET driver listed.  I will attach a screen shot to illustrate.  

Please note: The "MySQL Server" driver in the screenshot is the devart.com driver, not the MySQL Connector/Net driver. I only installed the devart.com solution after I could not get MySQL Connector/Net to work.  The issue with the MySQL Connector/NET 6.3.5 not appearing existed both before and after I installed the devart.com solution.

With respect to the other error, where the configuration screen errors out and automatically closes when I attempt to add a new connection using Server Explorer - the behavior is still occurring however the error message is no longer appearing so I can not take a screenshot.  What happens when I use Server Explorer and use "Add new connection" and change the data source to MySQL Database.  After clicking OK, it brings me to the "Add Connection" properties window where I can enter the server name, username, password and so forth.  If I type anything into the Server Name or Username textboxes it automatically closes the window and brings me back into the core of Visual Studio 2010.  I do not have this problem when I configure the connection properties for other drivers.

I noticed some similar posts on here about how other developers found information was missing from their machine.config files for MySQL.  I will attach my machine.config in case it helps.

I really appreciate your help Bogdan.  Thank you kindly for your time and quick response.

David
[23 Dec 2010 19:57] David Hanson
Screenshot Illustrating Available Drivers for Entity Data Model

Attachment: mysql_connector_6_3_5_bug_a.jpg (image/jpeg, text), 76.44 KiB.

[23 Dec 2010 20:18] David Hanson
Just to be clear:

The MySQL Database driver is only shown for the "add new connection" using the Server Explorer, but it is broken (closes when I press any key when on the properties screen).  The MySQL Database driver is not even available when I am using an Entity Data Model.

I will attach a screenshot that shows the MySQL Database driver that is available when I use Server Explorer.
[23 Dec 2010 20:18] David Hanson
Server Explorer > Add New Connection (shows driver, but properties dialog is broken)

Attachment: mysql_connector_6_3_5_normal.jpg (image/jpeg, text), 52.18 KiB.

[24 Dec 2010 3:48] Bogdan Degtyariov
Hi David,

Thank you for your comments and for the additional information.
I followed your steps and the driver was still in the list (please see the new screenshot vs_entity_net_2.jpg). It showed no errors or any error-like dialogs/warnings.

However, I found that your machine.config lacks the entry for MySql.Data.MySqlClient, which is present in my local C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config:

    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>

Can you try uninstalling Connector/NET 6.3.5 and installing it again?
Please make sure Visual Studio 2010 is not running at the moment when you run the connector setup MSI.
[24 Dec 2010 3:49] Bogdan Degtyariov
New Data Source wizard shows MySQL Connector/NET driver in the list

Attachment: vs_entity_net_2.jpg (image/jpeg, text), 99.04 KiB.

[24 Dec 2010 3:53] Bogdan Degtyariov
Connection Properties dialog for New Connection

Attachment: vs_entity_net_3.jpg (image/jpeg, text), 102.03 KiB.

[24 Dec 2010 4:44] David Hanson
Hi Bogdan,

Thank you for your all of your help and timely responses.

After following your suggestions, I can now confirm the issue is resolved.  I am not sure why the issue occurred in the first place, however I am very happy to have a fully working and integrated version of MySQL Connector/Net 6.3.5 with Visual Studio 2010 on Windows 7 64-bit.

These were the actions I took:
- Rebooted my computer
- Uninstalled MySQL Connector/Net 6.3.5
- Installed MySQL Connector/Net 6.3.5
- Confirmed I could add a new database connection using Server Explorer
- Confirmed MySQL Database driver was an option when creating an ADO.NET Entity Data Model

My best guess is the original installation of MySQL Connector/Net 6.3.5 was corrupt since the machine.config was only partially updated.  I know for a fact Visual Studio 2010 was not running when I performed the initial install of MySQL Connector/Net, however perhaps somehow something was still being locked.  The fresh reboot and install seemed to work like a charm.

In any case, thank you for all of your help Bogdan!!

David
[24 Dec 2010 5:24] Bogdan Degtyariov
David,

Thank you for your reply. I am glad to hear that the problem is resolved.
Since we cannot say for sure what caused the partial config update I am closing the report with the status "not a bug".
[24 Jan 2012 13:37] Neil Dodson
I have replicated this exact problem on 32bit Windows XP.
The "new data connection" dialog in visual studio vanishes on any keystroke and the section is missing from machine.config.

The described workaround (reinstalling the connector) solves the issue.