MySQL上的实体框架向导崩溃
我的问题类似于,但崩溃发生的时间较晚。我必须在SQL Server和MySQL之间互操作EF数据库第一个模型。更具体地说,我的应用程序根据连接字符串和配置设置(MySQL上的实体框架向导崩溃,mysql,entity-framework,visual-studio-2013,Mysql,Entity Framework,Visual Studio 2013,我的问题类似于,但崩溃发生的时间较晚。我必须在SQL Server和MySQL之间互操作EF数据库第一个模型。更具体地说,我的应用程序根据连接字符串和配置设置(DB_TYPE=MySQL)向SQL Server或MySQL发出普通SQL查询,这两个数据库具有相同的结构并一起维护,因此对一个模式的每次修改都会重新应用到另一个数据库 现在,我使用SQLServer数据库优先模型向应用程序添加了EF支持。我现在必须让应用程序也在MySQL上运行。为了验证老开发人员没有在两个DBMS之间留下不一致的东西
DB_TYPE=MySQL
)向SQL Server或MySQL发出普通SQL查询,这两个数据库具有相同的结构并一起维护,因此对一个模式的每次修改都会重新应用到另一个数据库
现在,我使用SQLServer数据库优先模型向应用程序添加了EF支持。我现在必须让应用程序也在MySQL上运行。为了验证老开发人员没有在两个DBMS之间留下不一致的东西,我尝试根据数据库更新模型*,这次我选择了与localhost上开发数据库的MySQL连接
单击下面屏幕上的Next
后,它将崩溃并返回到EDMX编辑器
我需要继续这个项目,我已经有一段时间了
这是我的Web.config片段:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</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.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
我怎样才能解决我的问题?我为VisualStudio重新安装了MySQL工具,但没有帮助
*我使用的是Visual Studio的本地化版本,所以我不知道所有命令的英文原版我不知道为什么会这样,但我进入我的NuGet软件包管理器,删除了MySql.Data.Entity(还检查了删除MySql.Data的依赖项)。我进入了我的.edmx,运行了“从数据库更新模型…”,一切正常
(注意:这也删除了我的实体框架,所以我不得不在使用NuGet Manager时添加它)
W…T…F
也许其他人可以证实这一点…我也有类似的问题。安装“MySql.Data 6.9.9”和“MySql.Data.Entity 6.9.9”Nuget软件包后,向导在该屏幕后崩溃。我给它附加了一个调试器,发现它是由MySql.Data.Entity.EF6.dll中的空引用异常引起的
我想可能不是这些包,因为我已经尝试重新安装它们,所以我想可能是MySQL安装Visual Studio与MySQL EF6 dll冲突的问题。我的解决方案就是重新安装最新的“MySQL for Visual Studio 1.2.6”:
可能是我有一个旧版本(没想到先检查一下,所以我无法确认)。当你环顾四周时,这似乎是一个常见的问题。我知道这条路,但迟到总比不迟到好
我最终删除并重新安装了visual studio 2015和mysql,然后从头开始。然后,我确保在整个过程中只带来需要的东西
使用nuget安装MySql.Data 6.9.9和MySql.Data.Entity 6.9.9。没有别的了
Nuget无法正确更改web配置,因此需要按如下所示进行更改
以前
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
之后
这个给我修好了。我不确定您是否需要重新安装,但确定您需要执行步骤2
祝你好运。我通过以下步骤解决了这个问题(请注意,我使用的是vs2015和.net 4.5)
1) 卸载您以前拥有的所有mysql连接器
2) 通过NuGet包删除所有mySQL引用
3) 下载mysql连接器v6.8.8
4) 下载后,转到项目并添加新安装的dll文件作为参考(位于安装路径中,通常为C:\Program files(x86)\MySQL\MySQL Connector Net 6.8.8\Assembly\v4.5)
5) 转到您的NuGet软件包并添加MySql.Data(版本6.8)和MySql.Data.Entity(版本6.8)
6) 构建您的解决方案,不再崩溃:)
希望这对您有所帮助我从
<entityFramework>.....</entityFramework>
。。。。。
到
。。。。。
一切正常
引用:在我的例子中,原因是安装的mysql连接器的版本与引用的mysql.Data.Entity的版本不同
当我引用同一个版本时,一切都变得正常了。我可以告诉你,connector 8.0.xxx和MySQL为MySQL Server 8提供的所有8.0.xxx dll都是完全失败的
一年多以来,出现了一个重大漏洞
如果您尝试使用MySql 8.0,许多连接器和库都会给您一个错误
“提供程序未返回ProviderManifestToken字符串。”
它证明了visual studio支持、文档和,在mysql dll的连接器和文档中应用了测试和基本开发技能,我在清醒的生活中花了40个小时试图建立一个工作模型,使我的应用程序与mysql 8.0.16连接,并拥有一个工作实体框架向导。在这一点上,我几乎希望我使用SQLServer开发它
我使用的是ASP.NET Identity 2.0的一个变体,这是我在尝试登录时得到的结果
“提供程序未返回ProviderManifestToken字符串。”
无论如何,这就是我要为我工作的东西
这是我在Windows 10上使用服务器8.0时得到的东西,该服务器进行连接,允许使用ASP.NET Identity 2.0登录,并且至少会运行数据实体向导完成
安装连接器/Net 6.10.7
动态链接库
c:..\EntityFramework.6.2.0\lib\net45\EntityFramework.dll
C:..\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll
C:..\MySql.Data.6.10.7\v4.5.2\MySql.Data.dll
C:..\MySql.Data.6.10.7\v4.5.2\MySql.Data.Entity.EF6.dll
Web.Config
<configSections>
<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="DefaultConnection" connectionString="server=localhost;user id=<yourid>;password=<yourpassword>;persistsecurityinfo=True;database=<yourdbname>" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<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, Version=6.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"></remove>
<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.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Web.Config
我希望这能帮助一些人,但我有一种奇怪的感觉,你的里程数
<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">.....</entityFramework>
Web.Config
<configSections>
<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="DefaultConnection" connectionString="server=localhost;user id=<yourid>;password=<yourpassword>;persistsecurityinfo=True;database=<yourdbname>" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<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, Version=6.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"></remove>
<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.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
Microsoft.EntityFrameworkCore (v5.0.0 – the latest stable version)
Microsoft.EntityFrameworkCore.Tools (v5.0.0 – the latest stable version)
Pomelo.EntityFrameworkCore.MySql (version 5.0.0-alpha.2)