EF Core 3.1迁移工具由于对.NET Core 2.0的依赖性而失败

问题描述 投票:0回答:1

我有一个使用EF Core 3.1的项目。启动项目是使用V3和框架3.1运行的Azure功能。其他项目是.NET Standard 2.0项目的类库。

我正在尝试为EF Core 3.1生成迁移脚本,并且从Azure DevOps得到以下错误

Starting: Run EF Core Migrations
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.163.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
dotnet ef migrations script --startup-project C:\vstsagent\A6\_work\2\s/MyProject/MyProject.Function.WebApi/MyProject.Function.WebApi.csproj --output C:\vstsagent\A6\_work\2\a/16138/Migrations/SqlScript.sql --context $dbContext --idempotent --verbose --framework netcoreapp3.1
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\vstsagent\A6\_work\_temp\3930c14d-f779-4939-9748-dd2ab8c6baa0.cmd""
Using project 'C:\vstsagent\A6\_work\2\s/MyProject/MyProject.Function.WebApi/MyProject.Function.WebApi.csproj'.
Using startup project 'C:\vstsagent\A6\_work\2\s/MyProject/MyProject.Function.WebApi/MyProject.Function.WebApi.csproj'.
Writing 'C:\vstsagent\A6\_work\2\s\MyProject\MyProject.Function.WebApi\obj\MyProject.Function.WebApi.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmp74C6.tmp /verbosity:quiet /nologo C:\vstsagent\A6\_work\2\s/MyProject/MyProject.Function.WebApi/MyProject.Function.WebApi.csproj
Writing 'C:\vstsagent\A6\_work\2\s\MyProject\MyProject.Function.WebApi\obj\MyProject.Function.WebApi.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\tmp77C5.tmp;TargetFramework=netcoreapp3.1 /verbosity:quiet /nologo C:\vstsagent\A6\_work\2\s/MyProject/MyProject.Function.WebApi/MyProject.Function.WebApi.csproj
Build started...

Build succeeded.
dotnet exec --depsfile C:\vstsagent\A6\_work\2\s\MyProject\MyProject.Function.WebApi\bin\Debug\netcoreapp3.1\MyProject.Function.WebApi.deps.json --additionalprobingpath C:\Windows\ServiceProfiles\NetworkService\.nuget\packages C:\Windows\ServiceProfiles\NetworkService\.dotnet\tools\.store\dotnet-ef\3.1.1\dotnet-ef\3.1.1\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations script --output C:\vstsagent\A6\_work\2\a/16138/Migrations/covImsSqlScript.sql --context $dbContext --idempotent --assembly C:\vstsagent\A6\_work\2\s\MyProject\MyProject.Function.WebApi\bin\Debug\netcoreapp3.1\MyProject.Function.WebApi.dll --startup-assembly C:\vstsagent\A6\_work\2\s\MyProject\MyProject.Function.WebApi\bin\Debug\netcoreapp3.1\MyProject.Function.WebApi.dll --project-dir C:\vstsagent\A6\_work\2\s\MyProject\MyProject.Function.WebApi\ --language C# --working-dir C:\vstsagent\A6\_work\2\s --verbose --root-namespace MyProject.Function.WebApi
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.
  - The following frameworks were found:
      3.1.0 at [C:\vstsagent\A6\_work\_tool\dotnet\shared\Microsoft.NETCore.App]
      3.1.1 at [C:\vstsagent\A6\_work\_tool\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win81-x64
##[error]Cmd.exe exited with code '-2147450730'.
Finishing: Run EF Core Migrations

当我查看执行dotnet.exe工具安装dotnet-ef -g]时要安装的工具的文件夹时>我可以看到存在一个仍在引用Framework 2.0的目录在运行dotnet ef迁移脚本的命令上。

C:\Windows\ServiceProfiles\NetworkService\.dotnet\tools\.store\dotnet-ef\3.1.1\dotnet-ef\3.1.1\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll

我唯一能想到的是EF Core 3.1需要将.NET Core 2.0也安装在构建服务器上才能正常工作。但是,这感觉不对。

有没有人遇到过类似的经历,除了安装.NET Core 2.0以外,您是否设法找到解决方案?

我有一个使用EF Core 3.1的项目。启动项目是使用V3和框架3.1运行的Azure功能。其余项目是.NET Standard 2.0 ...

c# entity-framework .net-core ef-migrations ef-core-3.1
1个回答
0
投票

我想我找到了问题所在。我缺少--project参数。但是,一旦我输入了它,我将收到以下错误:

© www.soinside.com 2019 - 2024. All rights reserved.