19

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

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

<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

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

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.

Thanks in advance

Community
  • 1
  • 1
Harshani
  • 649
  • 2
  • 9
  • 22
  • Could you post the complete exception message? I've e'en this error specifically foot MySQL before, but need to see if it is the same. And stacktrace too. – Xharze Apr 22 '12 at 22:36
  • It is just the error message I get when I click on the ok button after filling the form to create the contactcontroller. – Harshani Apr 23 '12 at 21:53
  • Please check, if connectingString is added to the correct Web.config file. It should be located in the root config file (not in the Views/Web.config) –  Aug 08 '12 at 19:23
  • I received this error because I moved to a new Virtual Machine with a fresh copy of my source code and I had forgotten to run Update-DataBase to deploy my EF6 database to my local database server. E.g. my database didn't exist. – Ryan Mann Aug 18 '14 at 19:24
  • possible duplicate of [EF 4.1 exception "The provider did not return a ProviderManifestToken string"](http://stackoverflow.com/questions/5423278/ef-4-1-exception-the-provider-did-not-return-a-providermanifesttoken-string) – Dude Pascalou May 27 '15 at 19:29

8 Answers8

23

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.

user1843594
  • 331
  • 2
  • 4
  • 1
    I was getting the error while using the EF Power Tools Reverse engineer (Code First), and your answer was spot on. I had specified the connection in the EF PowerTools, but was missing from the web.config of the destination application. Thanks for this! – hardba11 Dec 05 '12 at 17:51
  • The exact reason in my case. Thanks, user1843594! – Tomas Walek Nov 29 '13 at 08:37
  • A malformed conn string causes this as well. Due to a formatting error I had the port in my conn string twice (eg: "server.com:3306:3306") and got this error. – dlchambers Jul 27 '15 at 18:00
10

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

erdal
  • 421
  • 3
  • 10
5

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) and MySql.Data (latest version is 8.0.X). Those version numbers should match. You should use the MySql.Data.EntityFramework package with MySql.Data version 8.0 and after, and the MySql.Data.Entity package with versions 6.10 and before.

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

Tim Cooke
  • 862
  • 7
  • 14
3

The problem was with the MySQL connector/Net.

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/

Harshani
  • 649
  • 2
  • 9
  • 22
2

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

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" />
Ajay Suwalka
  • 549
  • 1
  • 7
  • 24
  • Sorry, sslmode=None; has to be added – Ajay Suwalka Jun 13 '18 at 06:46
  • the is my case. It could working fine previously. One day after you installed some software with SSL lib, then program could not connect to mysql without any info about SSL. Because default value of sslmode is preferred. – Keep Thinking Mar 04 '20 at 08:24
0

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

 connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=contacts;Integrated Security=True uid=root;pwd=password;" providerName="MySql.Data.MySqlClient"/>
Jayanga
  • 889
  • 6
  • 15
  • I tried to log in to the DB instance. It works fine. I also think the problem is with the connection string. Your solution also didn't work. – Harshani Apr 22 '12 at 18:33
  • You're using a providerName for "MySQL" when using MSSQL. – ilter Sep 25 '15 at 10:23
0

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 :)

Emad Alashi
  • 493
  • 6
  • 13
0

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.

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

Martin Staufcik
  • 8,295
  • 4
  • 44
  • 63