C# 提供者未返回 ProviderManifestToken 字符串实体框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18966113/
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-10 13:43:55  来源:igfitidea点击:

The provider did not return a ProviderManifestToken string Entity Framework

c#sqlvisual-studioentity-frameworkvisual-studio-2012

提问by Leyth G

An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.

从数据库获取提供者信息时出错。这可能是由实体框架使用不正确的连接字符串引起的。检查内部异常以获取详细信息并确保连接字符串正确。

Inner Exception: {"The provider did not return a ProviderManifestToken string."}

内部异常: {"The provider did not return a ProviderManifestToken string."}

I've searched other threads as there are many with similar errors, but I cannot seem to find a solution.

我搜索了其他线程,因为有很多类似的错误,但我似乎找不到解决方案。

I am using VS2012 Professional and SQL Server 2012. I am able to connect to the server using Server explorer using windows authentication. I am building a webforms application with multiple tiers. One of them containing my Entity framework tier which contains my Context class.

我使用的是 VS2012 Professional 和 SQL Server 2012。我能够使用 Windows 身份验证使用服务器资源管理器连接到服务器。我正在构建一个具有多层的 webforms 应用程序。其中之一包含我的实体框架层,其中包含我的 Context 类。

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>

  <connectionStrings>
    <add name="MYSQLSERVER"
         providerName="System.Data.SqlClient"
         connectionString="Data Source=myComputer\MYSQLSERVER;Trusted_Connection=true"></add>
  </connectionStrings>
</configuration>

This is what the app.config in my Entity Framework class library layer looks like.

这就是我的实体框架类库层中的 app.config 的样子。

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

Also, I have tried changing the app.config defaultConnectionFactory type to

另外,我尝试将 app.config defaultConnectionFactory 类型更改为

<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">

but it did not change anything.

但它没有改变任何东西。

I am not really sure what any of the changes I am making even mean which worries me. Sure I could of found the solution online and fixed my issue, but I would really like to understand the web.config and what this all means. On top of finding a solution to this problem, can anyone point me in the right direction to learning web.configs?

我真的不确定我所做的任何改变是什么意思,这让我感到担忧。当然我可以在网上找到解决方案并解决了我的问题,但我真的很想了解 web.config 以及这一切意味着什么。除了找到这个问题的解决方案之外,有人能指出我学习 web.configs 的正确方向吗?

Thank ahead for your help.

提前感谢您的帮助。

采纳答案by dotNET

In my case, it was my SQL Server instance that was not running. I simply started the service and everything worked fine. Hope this helps someone down the road.

就我而言,是我的 SQL Server 实例没有运行。我只是启动了服务,一切正常。希望这可以帮助某人在路上。

回答by Leyth G

Well I fixed it.

嗯,我修好了。

Just needed to put "." for localmachine in the data source as follows:

只需要放“。” 对于数据源中的 localmachine,如下所示:

<add name="MYSQLSERVER"
     providerName="System.Data.SqlClient"
     connectionString="Data Source=.\MYSQLSERVER;Trusted_Connection=true"></add>    
</connectionStrings>

回答by Richard Hammond

..and FINALLY(?!?) don't forget to build your project with 'Prefer 32-bit' checked as this will eliminate the KNOWN BUG which generates this error message (which has the inner exception message = 'Arithemtic overflow')

..最后(?!?)不要忘记在“首选 32 位”检查的情况下构建您的项目,因为这将消除生成此错误消息的已知错误(其中包含内部异常消息 = '算术溢出')

回答by user5091911

i meet this problem when i try to connect to mysql, the reason is that i forget to add the "password" in "connectionStrings"

当我尝试连接到mysql时遇到这个问题,原因是我忘记在“connectionStrings”中添加“password”

回答by dlchambers

Here's another possible cause:
I have both my (ASP.NET) HTTP server and MySQL/Aurora server on AWS (understood that AWS was not part of the OP's comments).
My desktop's (actually, our building's) IP was whitelisted in the MySQL/Aurora server's security group, so everything worked perfectly for development.
But the ASP.NET server's IP was notwhitelisted for the MySQL/Aurora instance, thus the ASP server's EF connection request was being rejected, and thatwas causing the exception noted at the top of this thread.
Esoteric, but maybe this helps someone.

这是另一个可能的原因:
我的 (ASP.NET) HTTP 服务器和 MySQL/Aurora 服务器都在 AWS 上(了解到 AWS 不是 OP 评论的一部分)。
我的桌面(实际上是我们大楼)的 IP 被列入 MySQL/Aurora 服务器安全组的白名单,所以一切都非常适合开发。
但是 ASP.NET 服务器的 IP没有被列入 MySQL/Aurora 实例的白名单,因此 ASP 服务器的 EF 连接请求被拒绝,导致了该线程顶部指出的异常。
深奥的,但也许这对某人有帮助。

回答by Leonidas Menendez

In my case the paramter was v12.0, I changed to v11.0 and it is working

在我的情况下,参数是 v12.0,我改为 v11.0 并且它正在工作

回答by Kirsy92

I had the same problem, reinstalling Npgsql with the package manager did the trick. Seemed to be a versionning problem.

我遇到了同样的问题,使用包管理器重新安装 Npgsql 可以解决问题。似乎是版本控制问题。

回答by Shadi Namrouti

For me, it was using double backslash between the server and the instance, such like .\SQLExPRESS;...etc.

对我来说,它在服务器和实例之间使用双反斜杠,例如 .\SQLExPRESS;... 等。

The correction was to use .\SQLEXPRESS

更正是使用 .\SQLEXPRESS

hope it helps someone.

希望它可以帮助某人。

回答by kgdc

I also faced to this error and I solve that downgrading these NuGet packages

我也遇到了这个错误,我解决了降级这些 NuGet 包的问题

MySql.Data - 6.9.12

MySQL.Data.Entity - 6.8.8

MySql.Data - 6.9.12

MySQL.Data.Entity - 6.8.8

this is my reference URLwhich I referred

这是我参考网址我所提到的

回答by Amol Bhavekar

For me, It was all of the below. 1. DB not allowed to connect to my dev environment. May be firewall restrictions. 2. Connection string had wrong credentials for the DB. So generally speaking, incorrect connection string.

对我来说,这就是以下所有内容。1. 不允许数据库连接到我的开发环境。可能是防火墙限制。2. 连接字符串的数据库凭据错误。所以一般来说,不正确的连接字符串。