How to install entity framework core to asp.net core 3 project using visual studio code

asp.net-core c# entity-framework-core visual-studio-code

Question

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?

1
1
11/11/2019 2:32:26 PM

Popular Answer

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.

1
11/13/2019 8:49:13 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow