MySQL 提供程序未返回 ProviderManifestToken 字符串错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10269682/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:04:06  来源:igfitidea点击:

The provider did not return a ProviderManifestToken string error

mysqlasp.net-mvc-3entity-frameworkdbcontext

提问by har

I am trying to create a web app using ASP.Net MVC3, Entity Framework and MySQL.

我正在尝试使用 ASP.Net MVC3、Entity Framework 和 MySQL 创建一个 Web 应用程序。

I have added the following code to my Web.Config file.

我已将以下代码添加到我的 Web.Config 文件中。

<connectionStrings>
    <add name="ContactContext" connectionString="server=localhost;database=contacts;uid=root;pwd=password;" providerName="MySql.Data.MySqlClient"/>

  </connectionStrings>

I also have created "Person" Model , "ContactContext" in the project "Contact_Me". When I try to create a "ContactController" including Person Model and Contact context, it gives me the following error

我还在“Contact_Me”项目中创建了“Person”模型、“ContactContext”。当我尝试创建包括人员模型和联系人上下文的“ContactController”时,它给了我以下错误

"Unable to retrieve metadata for "Connect_Me.Models.Persons". The provider did not return a ProviderManifestToken string"

“无法检索“Connect_Me.Models.Persons”的元数据。提供程序未返回 ProviderManifestToken 字符串”

MYSQ & MVC3 SQL connection error \ ProviderManifestToken but I am using MySQL, this is the closest question to mine. But the answer didn't solve my problem.

MYSQ & MVC3 SQL connection error \ ProviderManifestToken 但我使用的是 MySQL,这是最接近我的问题。但答案并没有解决我的问题。

Thanks in advance

提前致谢

采纳答案by har

The problem was with the MySQL connector/Net.

问题出在 MySQL 连接器/网络上。

I previously used MySQL connector/Net 6.3.5 and after I uninstalled it and installed MySQL connector/Net 6.5.4 the issue was fixed. You can find latest connectors at http://www.mysql.com/products/connector/

我以前使用过 MySQL 连接器/Net 6.3.5,在我卸载它并安装 MySQL 连接器/Net 6.5.4 后,问题得到了解决。您可以在http://www.mysql.com/products/connector/找到最新的连接器

回答by user1843594

I know this may be very basic for a couple of you guys, but this exception is also thrown in cases where EF is unable to locate a Connection String to use. If you-re working in a multi-layered application, make sure the connection String is added to your client application, instead of the class library that contains you data access code. Just my 2 cents.

我知道这对于你们中的一些人来说可能是非常基本的,但是在 EF 无法找到要使用的连接字符串的情况下也会抛出这个异常。如果您在多层应用程序中工作,请确保将连接字符串添加到您的客户端应用程序,而不是包含您的数据访问代码的类库。只有我的 2 美分。

回答by erdal

I got this error when my sql server was actually down. So, please be sure that your sql server is up and running.

当我的 sql server 实际关闭时,我收到了这个错误。因此,请确保您的 sql server 已启动并正在运行。

回答by Tim Cooke

You can also get this error if you upgrade Nuget references in an EntityFramework project that uses MySql.Data.Entity(latest version is 6.10.X) andMySql.Data(latest version is 8.0.X). Those version numbers should match. You should use the MySql.Data.EntityFrameworkpackage with MySql.Data version 8.0 and after, and the MySql.Data.Entitypackage with versions 6.10 and before.

如果在使用MySql.Data.Entity(最新版本为6.10.XMySql.Data(最新版本为8.0.X)的 EntityFramework 项目中升级 Nuget 引用,也可能会出现此错误。这些版本号应该匹配。您应该使用MySql.Data.EntityFrameworkMySql.Data 8.0 及之后MySql.Data.Entity版本的包,以及6.10 及之前版本的包。

There are a lot more details in this blog post: https://davidsekar.com/asp-net/mysql-error-the-provider-did-not-return-a-providermanifesttoken

这篇博文中有更多细节:https: //davidsekar.com/asp-net/mysql-error-the-provider-did-not-return-a-providermanifesttoken

回答by Ajay Suwalka

Sometimes this issue arises because of sslmode as well, For me the solution was to add sslmode=None to connection string

有时这个问题也是由于 sslmode 而出现的,对我来说,解决方案是将 sslmode=None 添加到连接字符串

I had to make a small change to my connection string from

我不得不对我的连接字符串从

<add name="Connection" connectionString="Server=SOMEHOST;Database=DB;Uid=USR1;Pwd=PASS1;" providerName="MySql.Data.MySqlClient" />

to

<add name="Connection" connectionString="Server=SOMEHOST;Database=DB;Uid=USR1;Pwd=PASS1;sslmode=None;" providerName="MySql.Data.MySqlClient" />

回答by Emad Alashi

Even though this is answered, but I have experienced the same problem and my in case it was in the connection string; I had the part "Integrated Security" when I really shouldn't have used it; I was relying on the database authentication.

即使这是回答了,但我也遇到了同样的问题,以防万一它出现在连接字符串中;当我真的不应该使用它时,我有“集成安全”部分;我依赖于数据库身份验证。

I removed the "Integrated Security=True" part and it worked perfectly :)

我删除了“Integrated Security=True”部分,它工作得很好:)

回答by Jayanga

May be the error is in your connection string. Have you tried to connect to your DB instance using the above log in. try changing the connection string

可能是错误在您的连接字符串中。您是否尝试使用上述登录连接到您的数据库实例。尝试更改连接字符串

connectionString="Data Source=.;Initial Catalog=contacts;Integrated Security=True uid=root;pwd=password;" providerName="MySql.Data.MySqlClient"/>

use above if you are using sql server, else if you are using sql express use below one

如果您使用的是 sql server,请使用上面的,否则如果您使用的是 sql express,请使用下面的一个

 connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=contacts;Integrated Security=True uid=root;pwd=password;" providerName="MySql.Data.MySqlClient"/>

回答by Martin Staufcik

Restarting the computer worked for me.

重新启动计算机对我有用。

While this message was showing, I did not find any differences between my computer [Windows 10] and the test server where the the application was deployed with the same configuration and was working correctly there and using the same database. It means the issue was probably not connected to the database running on the test server.

在显示此消息时,我没有发现我的计算机 [Windows 10] 与使用相同配置部署应用程序并且在那里正常工作并使用相同数据库的测试服务器之间存在任何差异。这意味着问题可能未连接到测试服务器上运行的数据库。

Worth mentioning is there were some Windows updates pending while restarting.

值得一提的是,重新启动时有一些 Windows 更新未决。