I’ve been doing some work for a website which would be deployed to Azure for both the website and the database. Here is a quick run-down on how the deploy situation went, an error that gave me fits and the final-fix.
First off, let me say I had this website entirely working on my local machine. Things were peachy. I began my fly-by-the-seat-of-my-pants-publish-process.
- Published the database.
- Changed my local connection string to point to the sql server on Azure.
- Did not think that would work but it was flawless.
- Confidence rose 1/2 point.
- Like a total renegade, I decided to simply leave the connection string pointed to Azure and publish the site.
- The login page came right up.
- The skies began to open and I was pretty sure I heard instruments at least being tuned up; no singing yet.
- I stopped and wrote a brief [draft] email saying “Hey guys the website is up!”.
- But before sending, years of experience and lessons taught by a harsh teacher named ‘Embarrassment’ whispered to me, “Run one final test to make sure the database connects.”
- I navigated to the registration page, wherein my first database call would happen, which would pull a simple list of countries for a drop-down box.
FAILURE. Dismal utter and complete no-account nonsense. Pack up the instruments, no need for music. Singers go back to your individual hobbies – maybe later we’ll sing.
To recap .. at this point I have published both the website and the database and they are fine …. individually.
They just won’t talk to each other.
It’s like two girlfriends, who met on Twitter, then start having phone conversations across the country and become BFFs over the phone. Then one day, they get in the same room immediately deciding they hate everything about each other and neither one will speak to the other one..
It was just like that.
So after some debugging I extracted this exception from the code.
No entity framework provider found for ‘system.data.sqlclient’
No amount of staring at the screen, scowling or just hitting F5 would fix it. Believe me I tried.
After an evening of research (read that as MSDN searches, StackOverflow threads and briefly considering a gold-plated membership to Microsoft support) I fixed it.
What was it you may ask?
This section was missing from my web.config.
<entityFramework>
<defaultConnectionFactory type=”System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework” />
<providers>
<provider invariantName=”System.Data.SqlClient” type=”System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer” />
</providers>
</entityFramework>
/facepalm
For some reason, when running locally, I needed that not.
Adding it fixed the entire world though. And adding it was as easy as running ‘Install-Package EntityFramework -Version 6.1.2’ in Package Manager Console.
File this under #lessonslearned. Hopefully this might help somebody else!