3

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

abatishchev
  • 98,240
  • 88
  • 296
  • 433
KingKerosin
  • 3,639
  • 4
  • 38
  • 77
  • 1
    Sounds like the connection string is not right, if it used to work, get the connection string from the old config and see if the schema portion of it matches what your using now. Or could just regen the context from the DB and let it build a new connection string for you. – TechneWare Feb 27 '15 at 21:36
  • @TechneWare: I am using the same conn-string as build from M$ in the 'EntitiesProject' project. So how could there be an error? Any ideas how I can check my conn-strings for being "good" ones? – KingKerosin Feb 27 '15 at 21:39
  • If it never worked: First of all: Remove all references in your project that you are not sure that you need. Then: What is your database? Please show your connection string. Connect in server explorer to your database. Connect to this database in VS. Follow an appropriate tutorial for your database to create EF Context (perhaps again). This is something very well known, it should not be a problem. Think your edmx and database do not match. – Mare Infinitus Feb 27 '15 at 21:46
  • Try running Install-Package EntityFramework from the Package Manager Console (from http://stackoverflow.com/questions/18455747/no-entity-framework-provider-found-for-the-ado-net-provider-with-invariant-name) – Sam Feb 27 '15 at 21:48
  • @MareInfinitus: It is (by now) a local SQL 10.0.5520.0 installation. MyConnString (as created by M$ is) 'connectionString="metadata=res://*/SurgeryManagementEntities.csdl|res://*/SurgeryManagementEntities.ssdl|res://*/SurgeryManagementEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=SurgeryManagement;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"' – KingKerosin Feb 27 '15 at 21:51
  • And how did you create the data access dlls? Model First or Database First or Code First? Also: do you use SqlServer or a filebased SqlServerExpress? Seems there is some mixture. – Mare Infinitus Feb 27 '15 at 21:59
  • @MareInfinitus: I used the DatabaseFirst approach with a local SqlExpress installation – KingKerosin Feb 27 '15 at 22:17

1 Answers1

3

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.

Mare Infinitus
  • 8,024
  • 8
  • 64
  • 113
  • Which one? My app.config in my DB-project, the app.config in my IO-project or the web.config in my WebSite-Project? Or all of them? – KingKerosin Feb 27 '15 at 21:53
  • The frontend application needs to configure the provider and to have there the connection string. There also EntityFramework dlls shall be referenced. This is somewhat ridiculous, but it works in most cases. – Mare Infinitus Feb 27 '15 at 21:56
  • As @Mare Infinitus says, all frontend applications that use the edmx files (you cannot have .config files in DLL projects, exception being web project, which have web.config) – Fernando Gonzalez Sanchez Feb 27 '15 at 21:59
  • 2
    Adding the to web.config seems to work. Therefore the answer is correct! And - believe me - i tried this also before. No idea what VS, M$ or maybe NSA is doing here... – KingKerosin Feb 27 '15 at 22:01
  • 1
    @FernandoGonzalezSanchez This is true for server dlls, which are then hosted in IIS which normally have the web.config. If self hosted, the service executable will have the connection string too, and they normally have a app.config. – Mare Infinitus Feb 27 '15 at 22:15