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

· February 16, 2011

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:

<connectionStrings>
  <add
   name="[Name from you dbcontext class]"
   connectionString="DataSource=|DataDirectory|AnyName.sdf"
  providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>

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 works as expected. I am happy!

Twitter, Facebook