【问题标题】:Error in provider Entity Framework MySQL提供者实体框架 MySQL 中的错误
【发布时间】:2013-11-11 11:52:05
【问题描述】:

我尝试在 MySQL 数据库中连接我的实体框架,但是当我连接时发生此错误

找不到具有不变名称“MySql.Data.MySqlClient”的 ADO.NET 提供程序的实体框架提供程序。确保提供程序已在应用程序配置文件的“entityFramework”部分注册。请参阅http://go.microsoft.com/fwlink/?LinkId=260882 了解更多信息。

这是我的类库带有实体的 appConfig

<?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>
<connectionStrings>
<add name="portallentesContext" connectionString="server=******;User Id=******;password=*********;Persist Security Info=True;database=portallentes"
  providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.data>
<DbProviderFactories>
  <remove invariant="MySql.Data.MySqlClient" />
  <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.6.4.0" />
</DbProviderFactories>
</system.data>

<entityFramework>
<providers>
  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.4.0" >
  </provider>
</providers>
</entityFramework>
</configuration>

【问题讨论】:

  • 您是否安装了适用于 .NET 的 MySQL 连接器?
  • 是的,我安装了 mySQL 连接器
  • 在包管理器控制台中,尝试运行这个命令Install-Package EntityFramework -Pre
  • 我也已经这样做了
  • 你有什么版本的实体框架?

标签: mysql asp.net asp.net-mvc-3 entity-framework


【解决方案1】:

在这里看看我的回答:https://stackoverflow.com/a/42588773/3652378

确保在调用程序集中有MySql.Data.dllreferenced(不仅在类库项目中,而且在调用类库的Web 应用程序/wcf 应用程序中)。

【讨论】:

    【解决方案2】:

    将MySql.Data.Entity.EF5.dll和MySql.Data.Entity.EF6.dll一起复制到bin目录下。

    【讨论】:

      猜你喜欢
      • 2011-05-17
      • 2013-10-07
      • 2017-04-26
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多