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
http://dev.mysql.com/downloads/connector/net/. 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.
<assemblies>
<add assembly="MySql.Data, Version=6.6.4.0,
Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Data.Entity, Version=6.6.4.0, Culture=neutral,
PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Web, Version=6.6.4.0, Culture=neutral,
PublicKeyToken=C5687FC88969C44D"/>
</assemblies>
And I added another section to the Web.Config file as follows,
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
ype="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data,
Version=6.6.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
</DbProviderFactories>
</system.data>
And voila, that solved the issue. I got the application up and running without Mysql
connector for .Net installed on the server.