Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

VS 2017RC migration (EF 6x/.NET 4.6 reference issue) #1001

Open
freshe opened this issue Feb 21, 2017 · 8 comments
Open

VS 2017RC migration (EF 6x/.NET 4.6 reference issue) #1001

freshe opened this issue Feb 21, 2017 · 8 comments

Comments

@freshe
Copy link

freshe commented Feb 21, 2017

Not sure if this is the right place for this.

I have a ASP.NET Core web project that references a business layer, that references a data layer.
The data layer is a .NET 4.6.2 project with EF 6x.
[Web (aspnetcore)] --> [BLL (aspnetcore)] --> [DAL (net46)]

This works fine in VS2015/project.json world.

The VS2017 migration went well without errors. I get this error when running the project.

"InvalidOperationException: 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"

Installing EF6 in my web project solves the problem but that is obviously not a solution.

Advice is appreciated!

@m4ss1m0g
Copy link

m4ss1m0g commented May 2, 2017

The issue is present also on VS2017 RTM

@mlorbetske
Copy link

@bricelam this has been fixed for the upcoming release, hasn't it?

@bricelam
Copy link

bricelam commented May 2, 2017

No idea. It sounds like Web.config (or maybe it should be App.config in ASP.NET Core projects) isn't getting loaded at runtime.

@bricelam
Copy link

bricelam commented May 2, 2017

Or it isn't present (which would explain why installing EF6 into the web app makes it work)

@freshe
Copy link
Author

freshe commented May 2, 2017

The problem is that EntityFramework.SqlServer.dll is not referenced/copied to the bin folder. Which it did prior to VS2017. Thats why it works to nuget in EF to the web project. I don't know if that is a EF issue or a VS issue though.

@bricelam
Copy link

bricelam commented May 2, 2017

That sounds like the classic MSBuild issue that's been plaguing us for years: It doesn't copy transitive dependencies unless they are explicitly referenced in the dependent the assembly. The best way to work around this issue is to use NuGet's new MSBuild PackageReference items instead of packages.config in your DAL project. See their NuGet PackageReference in Visual Studio Project Files article.

@freshe
Copy link
Author

freshe commented May 2, 2017

Thank you!

"At present, package references are supported in Visual Studio 2017 only, for .NET Core projects, .NET Standard projects".

Replacing my DAL (.NET Framework Class Library) project with a .NET Standard Class Library project and setting TargetFramework to net461 worked. Now using PackageReference instead of packages.config

@bricelam
Copy link

bricelam commented May 2, 2017

From NuGet is now fully integrated into MSBuild:

We are hard at work to bring full PackageReference support to these project types. Our goal is to eventually make PackageReference the default and move away from all other formats.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants