📅  最后修改于: 2022-03-11 14:48:40.881000             🧑  作者: Mango
public override void OnModelCreating(...)
{
modelBuilder.Entity()
// a position has zero or more Employees via property Employees
.HasMany(position => position.Employees)
// every Employee has exactly one Position
.WithRequired(employee => employee.Position)
// using foreign key Position_id
.HasForeignKey(employee => employee.Position_Id);
}