3. Implementation/Entity Framework
Entity Framework and MySQL
SSKK
2013. 9. 26. 05:59
Install the Provider
In order to connect to MySQL databases, we will need to install an appropriate ADO.NET and Entity Framework provider. Luckily, the provider we're using is available via NuGet.
- Inside PMC, run Install-Package MySQL.Data.Entities
We also need to register the provider. Open App.config, and anywhere inside the configuration element, add the following fragment.
< system.data > < DbProviderFactories > < add name = "MySQL Data Provider" invariant = "MySql.Data.MySqlClient" description = "Data Provider for MySQL" type = "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" /> </ DbProviderFactories > </ system.data > |
Add a Connection String
In order to connect to the right database, we need to add a connection string to the App.Config. Anywhere inside the configuration element, add the following fragment.
< connectionStrings > < add name = "ChinookContext" connectionString = "server=localhost;database=Chinook;User Id=root;password=P4ssw0rd" providerName = "MySql.Data.MySqlClient" /> </ connectionStrings > |
참고:
http://brice-lambson.blogspot.kr/2012/10/entity-framework-on-mysql.html
http://www.saotn.org/mysql-connector-net-entity-framework/
http://www.saotn.org/mysql-connector-net-6-6-4-0-partial-trust/