简体   繁体   中英

Dot Net Core 3.1 does not show up in Visual Studio 2019

I have two projects within the same solution. One is the data layer. which I created by "do.net ef dbcontext scaffold" command at the command prompt. The second is an web api project. both compile successfully, when no reference is added from one to another.

But when I add reference of the dataaccess library to the web api project, I get build error (in web Api proj).

"Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 3.1.6 directly to project"

I have Installed Dot NEt Core Sdk 3.1.302 I have installed the runtime also. But 3.1 does not show up in the Visual studio when i go to properties and try to change the target framework. All I see is upto dot.net core 2.2

If someone could help.

控制面板

DataAccess csproj file.

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

 <PropertyGroup>
 <OutputType>Exe</OutputType>
 <TargetFramework>netcoreapp2.2</TargetFramework>
 </PropertyGroup>

 <ItemGroup>
 <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6">
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  <PrivateAssets>all</PrivateAssets>
  </PackageReference>
  <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.6" />
 </ItemGroup>

 </Project>

Api proj file.

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

 <PropertyGroup>
 <TargetFramework>netcoreapp2.2</TargetFramework>
 <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
 </PropertyGroup>

<ItemGroup>
 <PackageReference Include="Microsoft.AspNetCore.App" />
 <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
 </ItemGroup>
 <ItemGroup>
 <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.6">
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  <PrivateAssets>all</PrivateAssets>
 </PackageReference>
 <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.6" />

 <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataLayer\DataLayer.csproj" />
</ItemGroup>

</Project>

Any help will be appreciated.

Change <TargetFramework.netcoreapp2.2</TargetFramework> to <TargetFramework.netcoreapp3.1</TargetFramework> in both projects.

And follow these guides:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM