iT邦幫忙

0

[筆記系列]C# Entity Framework Fluent API 寫法(code first)

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Entity<Student>()
                .HasMany(x => x.Professors)
                .WithMany(y => y.Students)
                .Map(x =>
                {
                    x.ToTable("ProfessorsStudentsRelation");
                    x.MapLeftKey("SerialId_P");
                    x.MapRightKey("SerialId_S");
                });
}

尚未有邦友留言

立即登入留言