I\'m working with EF5 in a MVC 4 aspnet website. Locally, everything works just fine, but when I publish it to the IIS and try to enter, I get the error
Change this part in your Web.config, according to the below code.(try this, it works to me.)
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
I faced similar issue and changing defaultConnectionFactory to be SqlConnectionFactory helped me solve it.
Old question but it just happened to me for different reasons mentioned in the other answers, so I thought I'd share my findings.
In my case, the problem was how I defined my connection string entry in the app.config. I edited it directly in Notepad++
and I must have hit a shortcut, and minimized the entire string which I didn't spot, and started to get this error. This is how I was defined it:
<add name="MyDb" connectionstring="data source=MyServer;
initial catalog=MyDatabase;integrated security=true"
providername="System.Data.SqlClient" />
The second I changed the following parameters
connectionstring to connectionString
and
providername to providerName
Note: The problem was highlighted immediately In Visual Studio but clearly this isn't ideal if you're on a client site!
I ran into this issue when I forgot to set my Connections.config file to "copy always"
BareMessage = "Unable to open configSource file 'Connections.config'."
Check the C-drive inside C:\inetpub\wwwroot and remove all unnecessary folders from it, else remove unnecessary host files or folders from IIS.
I had multiple provider
s specified in my web.config.
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
</providers>
I simply removed one of those and it worked.
I am using MySQL though, not TSQL