I am learning Entity Framework and trying to create a sample code using Code first approach. While running this code i am getting above mention error. I am developing code on VS 2012 and database is Microsoft SQL Server. it also shows error message as "Unable to find the requested .Net Framework Data Provider. It may not be installed."
I've developed 3 class files and one of this file is for interacting with database which throws error at:
public List<Standard> GetStandards()
{
StandardDBContext standardDBContext = new StandardDBContext();
return standardDBContext.Standard.Include("Student").ToList();
}
My web.config file:
<connectionStrings>
<add name="StandardDBContext" connectionString="server=CPC2\SQLEXPRESS; database=SchoolDatabase;User Id=sa;Password=password; integrated security=true" providerName="System.Data.SqlClient;" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</DbProviderFactories>
</system.data>
<entityFramework>
<!--<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0"/>
</parameters>
</defaultConnectionFactory>-->
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
Can any one please help me. Your help will be appreciated.
asked Jun 25, 2015 at 12:26
-
Check to see if EntityFramework.SqlServer.dll is in your /bin folder. If it's not, you might want to first try reinstalling the EF nuget package. stackoverflow.com/questions/21157069/…Steve Greene– Steve Greene06/25/2015 15:59:39Commented Jun 25, 2015 at 15:59
-
Hi Steve, I've already included EntityFramework.sqlserver.dll in my folder. And tried the link to get the solution but still it is not solved. Can you please help me to get this project run.Akshay– Akshay06/26/2015 08:01:39Commented Jun 26, 2015 at 8:01
-
1Have you tried removing EF and cleaning out the web.config and starting over? Are you referencing from a web forms/mvc project or from a data layer?Steve Greene– Steve Greene06/27/2015 16:07:12Commented Jun 27, 2015 at 16:07
-
Thanks for your help @Steve, i figured it out solution that made mistake in connection string with data source. So i configured it and it works fine. I appreciate your help. Thanks again for your precious time.Akshay– Akshay06/29/2015 06:07:32Commented Jun 29, 2015 at 6:07
default