1

I'm creating a new MVC application using visual studio code and I want to add entity framework core to my project. My application is using the latest .net core 3 but when I tried to install package Microsoft.EntityFrameworkCore.SqlServer its show an error like this

Unable to resolve 'Microsoft.EntityFrameworkCore.SqlServer (>= 3.0.0)' for '.NETCoreApp,Version=v3.0'

enter image description here

How can I solve this issue?

8
  • I was using this 'dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 3.0.0' to install the package, I got this from nuget.org. But still not working. Commented Nov 11, 2019 at 14:14
  • What is HealtcarePortal ? What kind of project is this ? Commented Nov 11, 2019 at 14:17
  • @Fabjan HealtcarePortal is my project name and this is an asp.net core mvc project Commented Nov 11, 2019 at 14:18
  • Does your project have a reference to Microsoft.AspNetCore.All in it? It might be an incompatibility with that that's causing this problem. Commented Nov 11, 2019 at 14:34
  • @Eifion I don't have any reference in it, Entity Framework core should be the first reference for my project. Commented Nov 11, 2019 at 15:20

1 Answer 1

1

ASP.NET Core 3.0 removes some assemblies that were previously part of the Microsoft.AspNetCore.App package reference.

You should add the package references for removed assemblies.

In XML project file:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UserSecretsId>My-secret</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0" />
  </ItemGroup>

</Project>

Take a look here.

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

3 Comments

when I try to copy it to .csproj and run dotnet restore, it gives me an error like this Unable to resolve 'Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (>= 3.0.0)' for '.NETCoreApp,Version=v3.0' same also to all.
It could be a problem of the local cache try on the console > dotnet nuget locals --clear all
still not working, I have searched all over the internet but all the same result.

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.