How to use MySql with asp.net

Visual Studio is a very powerful IDE and very rich in terms of development tools/plugin. NuGet make it more easier to resolve the library or framework dependency of projects.
.net with MySql Last week, I was working with a client who is starting his business in consultancy. He has a shared hosting (Delux plan on GoDaddy) which provides him 25 MySql databases along with 2 MS SQL databases. He has 2 web application running on this account, that means he has already consumed 2 MS-SQL databases. Now, for new web application which he wanted to build on Microsoft stacks, requires MS SQL database and for this he needs to buy additional one. But, he was not willing to expense much on this.

I suggested him to utilize his MySql database with asp.net application and in this way, without spending a penny, he will be able to have more than 2 windows/.net applications running on into his GoDaddy's Delux hosting account. Since, GoDaddy has limitation of 2 MSSQL database and not on .net application, it will be a good solution.

 
Well, coming to technical implementations from the long story :) It is very easy to use MySql from asp.net. You must have noticed 2 important things in our Visual Studio. The first one is we have a Server Explorer window which helps us in exploring the connected MS SQL server / database. Another important thing is the driver which connects our .net application to MSSQL database. 
 
Hope, you got my point. Since MySql is not from a Microsoft stacks, we would required to arrange these 2 items our-self.

1. MySql Connector/Driver for .Net

In order to connect MySql database, we will requires its connector driver. This can be downloaded from here Download Connector/Net 

2. MySql for Visual Studio IDE

This is a tool that need to be integrated with our Visual Studio IDE in order to get access of MySql objects in our Solution Exprorer window. It helps to access MySql objects & data from Visual Studio IDE. It can be downloaded from here Download MySQL for Visual Studio
This tool is a set of many functionality and provides the same thing as Microsoft does for MS SQL -
  • Query designer  
  • Entity Framework support 
  • Stored routine & debugging 
  • Server explorer integration 
  • MySql editor 
  • MySql database export tool 
  • Web configuration
This tool is very powerful and uses connector/driver internally for us while working with Entity Framework or Web configuration. For more exposure, you may refer - http://dev.mysql.com/doc/connector-net/en/connector-net-visual-studio.html
 
Once, you finished the setup of these duo, you are done. If you want to have a local MySql database then you need to install WAMP or like that on your machine. In our case, we directly created a database on the GoDaddy and used that.
 
Keep reading... In next post we will see practical aspect of this exercise and challenges fallen in.