using Indotalent.Data.Entities; using Indotalent.Shared.Consts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Indotalent.Infrastructure.Database.MsSQL.Configuration; public class SalesOrderItemConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.Property(e => e.SalesOrderId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.ProductId) .HasMaxLength(GlobalConsts.StringLengthId); builder.Property(e => e.Summary) .HasMaxLength(GlobalConsts.StringLengthShort); builder.HasOne(e => e.SalesOrder) .WithMany(e => e.SalesOrderItemList) .HasForeignKey(e => e.SalesOrderId) .OnDelete(DeleteBehavior.Cascade); builder.HasOne(e => e.Product) .WithMany() .HasForeignKey(e => e.ProductId) .OnDelete(DeleteBehavior.NoAction); builder.HasIndex(e => e.SalesOrderId); builder.HasIndex(e => e.ProductId); } }