public class TagProgramMap : EntityTypeConfiguration<TagProgram> { public override void Map(EntityTypeBuilder<TagProgram> builder) { builder.HasKey(t => new { t.ProgramId, t.TagId }); builder.HasOne(t => t.Tag).WithMany(t => t.TagPrograms).HasForeignKey(t => t.TagId) .OnDelete(DeleteBehavior.Restrict); builder.HasOne(t => t.Program).WithMany(t => t.TagPrograms).HasForeignKey(t => t.ProgramId) .OnDelete(DeleteBehavior.Restrict); } }
错误消息:InvalidOperationException: The entity type 'TagProgram' requires a primary key to be defined.
ef core版本是2.1