Azure DevOps 构建在更新到 .NET/EF Core 6 后失败,带有长(64 位整数)id 的 ModelShapShot 失败

Azure DevOps build fails after updating to .NET/EF Core 6, ModelShapShot with long (64bit int) id fails

将我的 ASP.NET 从 5 更新到 6 后,我遇到了一个非常奇怪的 Azure DevOps 问题,它使用 entity framework 和 SQL 服务器。我的构建管道设置为使用 .NET 6.0.x 和池中的 windows-2022 代理。我的 EF Core dll 是 6.0.2.

该项目在本地构建良好,但在 Azure devops 上使用 .NET 构建任务时,出现编译错误。它抱怨 'AppDbContextModelSnapshot.cs' 文件。似乎从 .NET5 到 6 已经将这些行添加到这个文件中,从这个开始:

b.Property<long>("Id")
     .ValueGeneratedOnAdd()
     .HasColumnType("bigint")
     .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

为此:

b.Property<long>("Id")
   .ValueGeneratedOnAdd()
   .HasColumnType("bigint");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);

注意:实体PK的类型是'long'。

此构建在本地运行,在本地迁移良好,但在部署到 Azure DevOps 进行构建时,会产生以下异常:

Data\Application\Migrations\AppDbContextModelSnapshot.cs(24,78):错误 CS1503:参数 2:无法从 'long' 转换为 'int'

我可以手动编辑生成的代码来删除争论,但为什么会抱怨?我在本地看不到代码有什么问题,也看不出这种转换是从哪里来的。根据 intellisense 告诉我的内容,这似乎很好:

为什么 Azure DevOps 上存在这种差异?

原来在我的 csproj 文件中有两个对 EF Core 库的引用,一个是旧版本。在某些时候一定是一个糟糕的合并。