1

I am having an issue when installing Entity Framework Core MSSQL in Visual Studio 2017 for OSX.

I run the below command and the package install correctly, but a few seconds later I get red (build?) errors showing up in all cs files.

What can I do to clear these errors?

dotnet add core-udemy package Microsoft.EntityFrameworkCore.SqlServer

Output

 ~/Projects/core-udemy  ⑂ master +    
dotnet add core-udemy package Microsoft.EntityFrameworkCore.SqlServer
  Writing /var/folders/fw/_y4_qxxd2ls2lh_dmwrdlp000000gn/T/tmpO0Tl4b.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore.SqlServer' into project '/Users/richardcurteis/Projects/core-udemy/core-udemy/core-udemy.csproj'.
log  : Restoring packages for /Users/richardcurteis/Projects/core-udemy/core-udemy/core-udemy.csproj...
info :   CACHE https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.sqlserver/index.json
warn : Detected package version outside of dependency constraint: Microsoft.AspNetCore.App 2.1.1 requires Microsoft.EntityFrameworkCore.SqlServer (>= 2.1.1 && < 2.2.0) but version Microsoft.EntityFrameworkCore.SqlServer 2.2.3 was resolved.
error: Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 2.2.3 directly to project core-udemy to resolve this issue. 
error:  core-udemy -> Microsoft.EntityFrameworkCore.SqlServer 2.2.3 -> Microsoft.EntityFrameworkCore.Relational 2.2.3 -> Microsoft.EntityFrameworkCore (>= 2.2.3) 
error:  core-udemy -> Microsoft.AspNetCore.App 2.1.1 -> Microsoft.EntityFrameworkCore (>= 2.1.1 && < 2.2.0).
info : Package 'Microsoft.EntityFrameworkCore.SqlServer' is compatible with all the specified frameworks in project '/Users/richardcurteis/Projects/core-udemy/core-udemy/core-udemy.csproj'.
info : PackageReference for package 'Microsoft.EntityFrameworkCore.SqlServer' version '2.2.3' added to file '/Users/richardcurteis/Projects/core-udemy/core-udemy/core-udemy.csproj'.
info : Committing restore...
log  : Generating MSBuild file /Users/richardcurteis/Projects/core-udemy/core-udemy/obj/core-udemy.csproj.nuget.g.props.
info : Writing lock file to disk. Path: /Users/richardcurteis/Projects/core-udemy/core-udemy/obj/project.assets.json
log  : Restore failed in 1.83 sec for /Users/richardcurteis/Projects/core-udemy/core-udemy/core-udemy.csproj.

My code then displays this on all class declarations...

Error: The type or namespace 'IConfiguration could not be found (are you missing a using directive or an assembly reference?)'

Error: Predefined type 'System.Object' is not defined or imported

Error: Predefined type 'System.Void' is not defined or imported

enter image description here

And

enter image description here

1 Answer 1

2

Typically, the error of "Version conflict detected" happens because there's something wrong with the versions of dependency graph.

error: Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 2.2.3 directly to project core-udemy to resolve this issue.

error: core-udemy -> Microsoft.EntityFrameworkCore.SqlServer 2.2.3 -> Microsoft.EntityFrameworkCore.Relational 2.2.3 -> Microsoft.EntityFrameworkCore (>= 2.2.3)

error: core-udemy -> Microsoft.AspNetCore.App 2.1.1 -> Microsoft.EntityFrameworkCore (>= 2.1.1 && < 2.2.0).

  1. As the information describes, your project depends on the Microsoft.AspNetCore.App v2.1.1, which requires the version of Microsoft.EntityFrameworkCore (2.1.1 && < 2.2.0).

  2. However, by using dotnet add core-udemy package Microsoft.EntityFrameworkCore.SqlServer, you're installing the "current" version of Microsoft.EntityFrameworkCore. The following screenshot from NuGet shows that you're installing the Microsoft.EntityFrameworkCore (2.2.3) :

enter image description here

Since you're using ASP.NET Core 2.1, you could install the related packages with an option of --version 2.1.* :

dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 2.1.*

It will result in a dependency as below:

<ItemGroup>

    ...

    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.*" />
</ItemGroup>

Once you fix the version conflict, you could run dotnet clean & dotnet restore & dotnet build, and then the second question will be solved.


Besides, the Microsoft.AspNetCore.App(v2.1.1) meta package has already set a dependency on Microsoft.EntityFrameworkCore.SqlServer (>= 2.1.1 && < 2.2.0) :

enter image description here

you don't need add such a package reference manually.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.