ef core3 中 HasForeignKey 和 ForSqlServerUseSequenceHiLo 方法的替代方法是什么?

What is alternative for HasForeignKey and ForSqlServerUseSequenceHiLo method in ef core3?

在使用 .net core 2.2 和 ef core 2.2 的项目中,我在 dbContext 中使用以下代码设置引用实体与其之间的一对多关系,在 OnModelCreating 中进行工作dbContext 的方法:

 modelBuilder.Entity<Reference>().OwnsMany<WorkDown>("WorkDowns", a =>
        {
            a.HasForeignKey("ReferenceId");
            a.Property(ca => ca.Action).IsRequired();
            a.Property(ca => ca.Note);
            a.Property(ca => ca.WorkDownId).ForSqlServerUseSequenceHiLo("WorkDownSequence");
            a.HasKey("WorkDownId");
        });

它在 .netcor 2.2 项目中完美运行,但在我使用 .net core 和 ef core 3 的另一个项目中,我找不到 HasForeignKeyForSqlServerUseSequenceHiLo 扩展方法在 efcore 3 中是否有任何替代方法或任何替代方法?

这是 3.0 的重大更改之一 - Configuration API for owned type relationships has changed:

The configuration related to the relationship between owner and owned should now be chained after WithOwner() similarly to how other relationships are configured. While the configuration for the owned type itself would still be chained after OwnsOne()/OwnsMany().

即您需要使用 WithOwner 重载之一才能访问关系配置方法,例如 HasForeignKey / HasPrincipalKey,例如

a.WithOwner()
    .HasForeignKey("ReferenceId");