Coldairarrow / EFCore.Sharding

Database Sharding For EFCore
Apache License 2.0
694 stars 144 forks source link

支持IEntityTypeConfiguration配置 #5

Closed Giant150 closed 4 years ago

Giant150 commented 4 years ago

特定的表要重写OnModelCreating 所以增加了IEntityTypeConfiguration配置支持 这样可以在Entity里增加OnModelCreating的配置 ` public class pbpd_modelmaterialEntityTypeConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder .HasKey(t => new { t.MaterialId, t.ModelId });

        builder.HasOne(pt => pt.Material)
            .WithMany(p => p.ModelMaterials)
            .HasForeignKey(pt => pt.MaterialId);

        builder.HasOne(pt => pt.Model)
            .WithMany(p => p.ModelMaterials)
            .HasForeignKey(pt => pt.ModelId);
    }
}

`