Wednesday, February 16, 2011

Error “The provider did not return a ProviderManifestToken string” with SQL Compact Edition

I was totally terrified when this happened to my yesterday. I had prepared a little website to use on a SpecFlow demonstration. I had run it several times and it worked fine. But all of a sudden – when I was doing one of those “just checking” it failed on me with this (“The provider did not return a ProviderManifestToken string”) error.

The site was using Entity Framework Code first with SQL CE as described here

Goggling for it didn’t help me to much but I suddenly realized that something was missing. I had used MvcScaffolding to create the database, but I hadn’t added any entries into the .config. Neither had MvcScaffolding but it was totally a slip from me. So I simply added this:

name="[Name from you dbcontext class]"


A few words here:

  • When adding this connection string the database got created. You might have to regenerate it (simply update your model to do), I’m not sure about that
  • You need the name of the connection string should equal the name of the DbContext class that your using
  • What or where the site got it’s data from before this I don’t know. There was no database present in the App_Data-directory before I did this fix. Confused smile

My demo-site is saved. My demos for SpecFlow run. I am happy!


Ricky Lundstål said...

Hi Marcus! (Long time, no see :-)

I stumbled over the exact same thing, and also asked "where the heck is my data?".

Found out that it is stored in your local SQL Express instance, i.e. .\SQLEXPRESS.


Marcus Hammarberg said...

Hello sir!

Nice to have such prominent visitors to the site.

And great detective work as well. Into the default instance feels quite obvious but I didn't think about looking there...

See ya!

quiznilo said...

Perfect! Found this after hours of searching and it helped the most. I was trying to use the new code-first approach with POCO objects. I had it fine with the default SQL Express connections, but couldn't figure out how to make EF use SQL CE!

Make sure you are trying to use SQL CE 4.0 as EF 4.1 doesn't provide connection support to SQL CE 3.5.

also, make sure you have this in your app:
Database.DefaultConnectionFactory =
new SqlConnectionFactory("Server=Microsoft SQL Server Compact Data Provider");

Thanks so much.

Bob MacNeal said...

Sweet. I thought this would take hours to debug. Thanks!

Bob MacNeal said...
This comment has been removed by the author.
Anonymous said...

Thanx Lot i resolve my problem... thanx a lot

Anonymous said...