本文整理汇总了C#中EntityTypeConfiguration.HasRequired方法的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration.HasRequired方法的具体用法?C# EntityTypeConfiguration.HasRequired怎么用?C# EntityTypeConfiguration.HasRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityTypeConfiguration
的用法示例。
在下文中一共展示了EntityTypeConfiguration.HasRequired方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Define
internal static void Define(EntityTypeConfiguration<Domain.ItemInstance> config)
{
config.HasRequired(r => r.Item)
.WithMany(r => r.OwnedBy)
.HasForeignKey(fk => fk.ItemId)
.WillCascadeOnDelete(false);
config.HasRequired(r => r.Owner)
.WithMany(r => r.Items)
.HasForeignKey(fk => fk.OwnerId)
.WillCascadeOnDelete(false);
}
示例2: buildProductDocs
protected void buildProductDocs(EntityTypeConfiguration<ProductDoc> productDocEntity)
{
productDocEntity
.HasKey(x => new { x.blobID, x.productID });
productDocEntity
.HasRequired(x => x.product)
.WithMany(x => x.files)
.HasForeignKey(x => x.productID);
productDocEntity
.HasRequired(x => x.blob);
}
示例3: buildOrderItems
protected void buildOrderItems(EntityTypeConfiguration<OrderItem> orderItemEntity)
{
orderItemEntity
.HasKey(x => new { x.productID, x.orderID });
orderItemEntity
.HasRequired(x => x.order)
.WithMany(x => x.products)
.HasForeignKey(x => x.orderID);
orderItemEntity
.Property(x => x.quantity)
.IsRequired();
}
示例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();
}