报错如下:
System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
--- End of inner exception stack trace ---
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
解决方案如下:
1、在EF所在项目中增加Mysql.data.dll,MySql.Data.Entity.dll,MySql.Web.dll这三个的引用,并且copy 到本地(在部署的时候这三个文件需要扔到bin目录下)
2、把mysql.data.dll添加到web.config中,添加方法如下:(版本跟token会根据不同的dll不同,你自己调整)
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,
Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
参考资料:http://support.appharbor.com/discussions/problems/2687-solved-mysql-provider-with-entity-framework-problem