Entity Framework 6.0 in MVC 5 project not working

KingKerosin

My current setup:

VS1013-Solution

  • MvcProject (MVC5)
  • FrameworkProject (ClassLibrary) - BaseController, BaseViewModel, ets.
  • EntitiesProject (ClassLibrary) - The edmx only as .cs file
  • EntitiesProjectIO (ClassLibrary) - InBetweenLayer to fetch get/set data in the underlying database

I added references to 'EntitiesProjectIO' to my 'MvcProject' and made a call to 'GetData(...)'.

Schema specified is not valid. Errors: \r\nSurgeryManagementEntities.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

is the message I get and I have now idea what the *** is going on. I already added references to nearly every known assembly, copied files from the DB-only project (EntitiesProject). Also copied EntityFramework.dll, tried NuGet for the prjects referencing the DB-Library... Edited the web.config, App.config, whatever.config. Still the same error

Update:

It's a brand new project/solution created within VS2013. Therefore I have no upgrade-issues or something else. Just a clean new solution...

Fernando Gonzalez Sanchez

Your frontend config file must have the provider registered like this:

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

The app config should have been modified after you added Entity Framework 6 thru nuget (which should have also added references to assembly EntityFramework.dll and EntityFramework.SqlServer.dll), you do that by issuing an "Install-Package EntityFramework -Version 6.0.0" in the Package Manager Console. (notice there are newer versions, see https://www.nuget.org/packages/EntityFramework).

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

Your project also needs to target .NET 4 or .NET 4.5 to use EF6.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Entity framework error in MVC5 project

Add Entity Framework 7 to an MVC 5 project

Struggling using MVC 5 and Entity Framework 6

Entity Framework 7 With Existing Database in .Net 5 MVC 6

entity framework savechanges not Working MVC

Entity DataSource not working with Entity Framework 6 Upgrade

How to Use Entity Framework 6.x in Asp.Net 5 (MVC 6)

Dot Net 6 Entity Framework Core project using Swagger is not working the way Microsoft suggests

Add test project to MVC with Entity Framework

.net MVC entity framework SaveChanges does not working

Entity Framework 6, validation not working as intended

Entity Framework 6 Lazy Loading not working

Entity Framework 6 - lazy loading not working

Exception to handle while working with Entity Framework 6

Interception not working as expected with Entity Framework 6

How can I map tables using fluent API in ASP.NET MVC 5, Entity Framework 6?

Authentication and Authorization without Entity Framework in ASP.NET 5 MVC 6

ASP.NET MVC5 Entity Framework 6 get bool = true and bool = false LINQ

How to save custom model in ASP.NET MVC 5 with Entity Framework 6?

entity framework code first migration working in EF5 but not in EF6

How to downgrade Entity framework from 6 to 5?

Entity Framework 5 and 6 in the same application

Entity Framework 6 "HasRequired" and "WithMany" partially working - not working as expected

Seeding Entity Framework Core 6 + .NET6 not working

Is it proper form to extend a model object (e.g. Product) and add a Create() method that inserts into the database? (MVC 5 Entity Framework 6)

ASP.NET MVC Unit Test Project Entity Framework error

.NET Core Web API project and Entity Framework 6 null exception

Can you export an Entity Framework 6 model into a database project?

Can Entity Framework 6 be used in a .NET Standard project?