原文 [Entity Framework] MySQL @ Entity Framework 6
要让MySQL能够用EF6,我花了一点时间,在此记录一下
在设定档加入Provider
从NuGet安装MySql.Data.Entities
完成后,就会看到相关元件已经被加入到专案里
接下来加入MySQL的Model
无法使用EF6
这时需要在App.config/Web.Config加入以下Provider,然后按下存档
< provider invariantName ="MySql.Data.MySqlClient" type ="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" ></ provider >
完整设定档如下:
<? xml version ="1.0" encoding ="utf-8" ? > < configuration > < configSections > <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> < section name ="entityFramework" type ="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission ="false" /> </ configSections > < startup > < supportedRuntime version ="v4.0" sku =".NETFramework,Version=v4.5" /> </ startup > < entityFramework > < defaultConnectionFactory type ="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework" > < parameters > < parameter value ="v11.0" /> </ parameters > </ defaultConnectionFactory > < providers > < provider invariantName ="System.Data.SqlClient" type ="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> < provider invariantName ="MySql.Data.MySqlClient" type ="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" ></ provider > </ providers > </ entityFramework > </ configuration >这时候就可以加入MySQL Model
文章出自: http://www.dotblogs.com.tw/yc421206/archive/2014/03/14/144395.aspx
若有谬误,烦请告知,新手发帖请多包涵
[Entity Framework] MySQL @ Entity Framework 6,布布扣,bubuko.com