Entity Framework 6.0 in MVC 5 project not working

asp.net-mvc c# entity-framework entity-framework-6

Accepted Answer

You need to register the provider as follows in your frontend configuration file:

<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>

After installing Entity Framework 6 using nuget, the app configuration should have been changed to include references to the EntityFramework.SqlServer.dll and EntityFramework.dll assemblies. To achieve this, issue the command "Install-Package EntityFramework -Version 6.0.0" in the Package Manager Console. (Note: Newer versions are available; see https://www.nuget.org/packages/EntityFramework.)

Following that, simply rebuild the solution (so the app config gets copied to the output folder of the project, where the EDMX designer will look for it).

To use EF6, your app must also target.NET 4 or.NET 4.5.

3
2/27/2015 10:10:32 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow