views:

298

answers:

4

I am using ASP MVC to develop a new project. I am using the repository pattern for Data Access. I have worked on the same scenario before using SQL Server, but now I'm using MySQL.

How do I interact with MySQL using the repository pattern?

+1  A: 

Database layer usually takes care of:

  • Establishing a connection to a database
  • Converting application-level data types to database datatypes
  • Wrapping/isolating upper application level from executing directly a query

Regarding database-specific components, usually these are SqlConnection, SqlDataReader, SqlCommand etc. They are Microsoft SQL Server specific. You will need to install MySql connector and use the supplied interface.

Look here: Using MySQL Native .NET Providers

You will work with these objects: MySqlConnection, MySqlCommand, MySqlDataReader, MySqlDataAdapter, MySqlParameter, MySqlTransaction.

Developer Art
A: 

You will need to setup/install a MySql data provider.

Kris Krause
A: 

use subsonic seems to be the fastest route to MySQL with MVC, or the newer versions of the mysql data provider allow for entity framework to be used also.... but again fastest route has to be subsonic your up and running in mins

minus4
+1  A: 

You could use an open source ORM like nHibernate and develop your repository layer. This supports MySQL. Then if you decide to switch back to SQL Server you'll only have to change 1 config line.

manu08