You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
|
|
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
|
|
|
|
public class CatalogItemConfiguration : IEntityTypeConfiguration<CatalogItem>
|
|
{
|
|
public void Configure(EntityTypeBuilder<CatalogItem> builder)
|
|
{
|
|
builder.ToTable("Catalog");
|
|
|
|
builder.Property(ci => ci.Id)
|
|
.UseHiLo("catalog_hilo")
|
|
.IsRequired();
|
|
|
|
builder.Property(ci => ci.Name)
|
|
.IsRequired(true)
|
|
.HasMaxLength(50);
|
|
|
|
builder.Property(ci => ci.Price)
|
|
.IsRequired(true)
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
builder.Property(ci => ci.PictureUri)
|
|
.IsRequired(false);
|
|
|
|
builder.HasOne(ci => ci.CatalogBrand)
|
|
.WithMany()
|
|
.HasForeignKey(ci => ci.CatalogBrandId);
|
|
|
|
builder.HasOne(ci => ci.CatalogType)
|
|
.WithMany()
|
|
.HasForeignKey(ci => ci.CatalogTypeId);
|
|
}
|
|
}
|
|
|