Ok, this may not be related to EF. I am trying to use the code-first feature and following is what I wrote:-
var modelBuilder = new ModelBuilder();
v
You should add the System.Data.SqlClient as the value to a new attribute named "ProviderName". Just like below :-
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="AddressBook" providerName="System.Data.SqlClient" connectionString="Data Source=MyMachine;Initial Catalog=AddressBook;Integrated Security=True;MultipleActiveResultSets=True;"/>
</connectionStrings>
</configuration>
I had the same error when I uploaded my website to the production server. My connection string had the providerName
property set. The cuase of the problem was a connection string in machine.config
named LocalSqlServer
and a role provider that has used that connection string:
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
....
So all I had to do was clearing connection strings and role providers before registering mine:
<connectionStrings>
<clear/>
<add name="DbEntities" connectionString="..." providerName="System.Data.SqlClient" />
</connectionStrings>
...
<roleManager defaultProvider="DefaultRoleProvider" enabled="true">
<providers>
<clear/>
<add name="DefaultRoleProvider" ... />
</providers>
</roleManager>