1

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.

Akshay
  • 77
  • 1
  • 1
  • 6
  • 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. http://stackoverflow.com/questions/21157069/unable-to-find-the-requested-net-framework-data-provider-it-may-not-be-install – Steve Greene Jun 25 '15 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 Jun 26 '15 at 08:01
  • 1
    Have 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 Jun 27 '15 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 Jun 29 '15 at 06:07

0 Answers0