Using Entity Framework with Mysql without the Mysql Connector for .Net Installed

Using Object Relational Mapper ORM, at the data access layer can make enterprise software development to be fun, because it takes the developers mind of the logical schema of the data store and programming at the data access layer can be done using an object oriented approach. With Entity Framework and Language Integrated Query LINQ by Microsoft programming is worth doing.

I had always used Entity Framework with Microsoft Sql Server as my data store while harnessing the power of LINQ in the process. But recently, I worked on a web application that required me to use a different data store entirely; Mysql while ORM must still be used at the data access layer. Since Visual Studio 2012 is my development tool, I had to download Mysql connector for .Net so as to be able to use entity framework with Mysql which can be found Entity framework can be used with various data stores so far their connectors are installed on the development machine.

With the Mysql data connector installed, everything worked fine on my development machine. But at the shared hosting server where the application would be deployed, series of issues came up, because the Mysql connector was not installed on the server. Wondering why it was not installed on the server, I picked up my phone and called the customer service unit of the web hosting company only to be told that they don’t install third party connectors on their server.

 I did some low level digging and exploration to determine the core dll files of the Mysql connector. I found MySql.Data.dll MySql.Data.Entity.dll and MySql.Web.dll which are located in the assemblies folder of the Mysql connector Installation folder. I copied the files into the bin folder of the web application. I modified the Web.Config file and added the section to it so that the dll files would be registered on the hosting server machine.
<add assembly="MySql.Data, Version=,
Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Data.Entity, Version=, Culture=neutral,
<add assembly="MySql.Web, Version=, Culture=neutral,

And I added another section to the Web.Config file as follows,
 <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
 description=".Net Framework Data Provider for MySQL"
 Version=, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>

And voila, that solved the issue. I got the application up and running without Mysql connector for .Net installed on the server.

Share this page on

5 Comment(s)   6 People Like(s) This Page   Permalink  

 Click  To Like This Page

comments powered by Disqus

Older Comment(s)

Posted by    Jan

Thursday, November 29, 2012    11:47 AM

Is your webapp running in Full trustlevel? I can't think of a way of loading MySql.Data, MySql.Web and MySql.Data.Entity without a server configuration in anything less or equal to Medium trust. For Medium -partial- trust, you need a configured MySqlClientPermission class.

Posted by    Ayobami Adewole

Saturday, December 01, 2012    1:45 PM

Yes, the application is running in full trust level

Posted by    Batz

Friday, January 18, 2013    10:05 AM

I got the same problem. But in my site i dont have bin file but only App_Code and App_Data files so where do I upload the MySQL dll files? can you provide me a solution Thank You

Posted by    Ayobami Adewole

Friday, January 18, 2013    6:06 PM

On your local machine, if you have installed the MySql connector for .net,in your project right click the web site folder and select add reference from the pop up menu and then browse to C:\Program Files\MySQL\MySQL Connector Net 6.6.4\Assemblies\v4.0 to select the necessary assemblies, this will create a bin folder in your project and add the files automatically.