0

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?

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.