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.
My demo-site is saved. My demos for SpecFlow run. I am happy!
7 comments:
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.
Regards
/Ricky
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!
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.
Sweet. I thought this would take hours to debug. Thanks!
Thanx Lot i resolve my problem... thanx a lot
I WAS STRUCK NEARLY ONE HOUR THEN I SOLVE MY PROBLEM .. THANQ U VERY MUCH...
Post a Comment