【发布时间】:2015-11-12 01:00:54
【问题描述】:
我有 Visual Studio Community 2015,我有一个类库项目。我已经通过 nuGet 添加了 Entity Framework 6、Mysql.Data、MySql.Data.Entity 和 MySql.Net(甚至不确定是否需要)包。
但是,当我通过向导向项目添加 ADO.Net 实体模型时,我得到了“选择您的版本”,但我收到一条错误消息,指出“您的项目引用了最新版本的实体框架;但是,无法为您的数据连接找到与此版本兼容的实体框架数据库提供程序......"
我的App.config如下
<?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="MyContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=hapangodb;uid=root;password=********" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<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, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
</provider></providers>
</entityFramework>
<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.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.6.4.0" newVersion="6.6.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我已经尝试卸载并重新安装所有 mysql 组件,但仍然遇到同样的问题。多年来,我一直在使用 mysql 的实体框架,没有任何问题,但自从有了一台新笔记本电脑后,我似乎无法让它工作......
到底发生了什么?
【问题讨论】:
-
您的项目需要哪个版本的 dotnet 框架?您可以尝试使用不同的版本。
-
我使用的是框架 4.5
-
试试framework 4.0。可能存在某种版本偏差。
-
试了 4 次还是同样的问题
标签: c# mysql .net entity-framework-6 visual-studio-2015