Setting up .NET MVC3 with MySQL

2019-05-18 13:33发布

问题:

Hy Guys,

How can I configure the webconfig to access a mysql db using MVC 3?

To use SQLExpress I included this code to configure in an example...

<add name="MovieDBContext"
     connectionString="Server=.\SQLEXPRESS;
     Database=Movies;Trusted_Connection=true"
     providerName="System.Data.SqlClient" />

I'm using Entity Framework.

PS.: I don't want to automatically create tables with the MVC. I want to create them manually.

Thks!

回答1:

Take a look at this post, it seems like your best option is to use MySql Connector with EF

Using MySQL with Entity Framework

your connection string should look something like:

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;