📜  实体类型具有 [Key] 属性的多个属性. - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:38.440000             🧑  作者: Mango

代码示例1
public class NorthwindContext : DbContext
{
     public NorthwindContext(DbContextOptions options):base(options) { }

     public NorthwindContext() { }

     protected override void OnModelCreating(ModelBuilder builder)
     {
         builder.Entity().HasKey(table => new {
         table.FriendId, table.UserId
         });
     }
     public DbSet Relationships { get; set; }
     public DbSet Users { get; set; }
}