首页 > 解决方案 > .csproj 文件在构建解决方案时自动更改?

问题描述

由于各种实体框架版本不兼容,我无法搭建 Razor 页面,因此我安装了所有版本 5.0.x 并更新了 .csproj 文件。但是当我构建解决方案时,它会变回以前的版本。

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Content Remove="Views\Logsign\signup.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.15" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.15">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
  </ItemGroup>

</Project>

标签: c#visual-studioentity-frameworkasp.net-corecsproj

解决方案


您是否将 TargetFramework 更改为 5.0?

<PropertyGroup>
   <TargetFramework>netcoreapp5.0</TargetFramework>
</PropertyGroup>

推荐阅读