本文整理汇总了C#中EntityTypeConfiguration.HasMany方法的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration.HasMany方法的具体用法?C# EntityTypeConfiguration.HasMany怎么用?C# EntityTypeConfiguration.HasMany使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityTypeConfiguration
的用法示例。
在下文中一共展示了EntityTypeConfiguration.HasMany方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buildCustomers
protected void buildCustomers(EntityTypeConfiguration<Customer> customerEntity)
{
customerEntity
.HasKey(x => x.customerID)
.Property(x => x.name).IsRequired()
.HasMaxLength(50);
customerEntity
.HasMany(x => x.orders)
.WithRequired(x => x.customer)
.HasForeignKey(x => x.customerID)
.WillCascadeOnDelete();
customerEntity
.Property(x => x.timeStamp)
.IsRequired();
}
示例2: configureEntity
/// <summary>
/// Configure LongShortUrl entityTypeConfiguration
/// </summary>
/// <param name="modelBuilder"></param>
private static void configureEntity(EntityTypeConfiguration<LongShortUrl> entityTypeConfiguration)
{
entityTypeConfiguration.HasKey(e => e.Id);
entityTypeConfiguration.Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
entityTypeConfiguration.Property(e => e.ShortUrlId).IsRequired().HasMaxLength(10);
entityTypeConfiguration.Property(e => e.LongUrl).IsRequired().HasMaxLength(2000);
entityTypeConfiguration.Property(e => e.CreatedDate).IsRequired();
entityTypeConfiguration
.HasMany(e => e.LongShortUrlUsers)
.WithOptional()
.HasForeignKey(e => e.LongShortUrlId)
.WillCascadeOnDelete();
}
示例3: buildProducts
protected void buildProducts(EntityTypeConfiguration<Product> productEntity)
{
productEntity
.HasKey(x => x.productID)
.Property(x => x.name)
.HasMaxLength(50);
productEntity
.Property(x => x.price)
.IsRequired();
productEntity
.Property(x => x.timeStamp)
.IsRequired();
productEntity
.HasMany(x => x.files)
.WithRequired(x => x.product)
.HasForeignKey(x => x.productID)
.WillCascadeOnDelete();
}
示例4: buildOrders
protected void buildOrders(EntityTypeConfiguration<Order> orderEntity)
{
orderEntity
.HasKey(x => x.orderID)
.Property(x => x.orderDate)
.IsRequired();
orderEntity
.Property(x => x.status)
.IsRequired();
orderEntity
.Property(x => x.address)
.IsRequired()
.HasMaxLength(400);
orderEntity
.Property(x => x.timeStamp)
.IsRequired();
orderEntity
.HasRequired(x => x.customer)
.WithMany(x => x.orders);
orderEntity
.HasMany(x => x.products)
.WithRequired(x => x.order)
.WillCascadeOnDelete();
}
示例5: MapPerson
protected override void MapPerson(EntityTypeConfiguration<Person> config)
{
base.MapPerson(config);
config.HasMany(p => p.Kjøp).WithRequired(k => k.Person);
}
示例6: Configurate
public static void Configurate(EntityTypeConfiguration<Dish> config)
{
config.HasMany(e => e.Delicious).WithMany()
.Map(m => m.ToTable("Delicious"));
}