简体   繁体   中英

The provider did not return a ProviderManifestToken string Entity Framework

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."}

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.

<?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.

<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

<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?

Thank ahead for your help.

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.

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

MySql.Data - 6.9.12

MySQL.Data.Entity - 6.8.8

this is my reference URL which I referred

Well I fixed it.

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

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

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 not whitelisted for the MySQL/Aurora instance, thus the ASP server's EF connection request was being rejected, and that was causing the exception noted at the top of this thread.
Esoteric, but maybe this helps someone.

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.

For those getting this recently, in updating to MySql.Data 8.0.19 you also have to update your references for EntityFramework, Oracle changed the package, it's now MySql.Data.EntityFramework instead of MySql.Data.Entity or MySql.Data.Entities. Props to David Sekar: https://davidsekar.com/asp-net/mysql-error-the-provider-did-not-return-a-providermanifesttoken

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

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

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

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

The correction was to use .\SQLEXPRESS

hope it helps someone.

I often forget why this error comes often. For me its usually I have changed credential of the database and did not change the same on the code section. Just in case if I come here again to remind myself.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM