namespace LiteCharms.Features.MidrandBooks.Orders.Entities; public sealed class OrderItemConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("OrderItems"); builder.HasKey(oi => oi.Id); builder.Property(oi => oi.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()"); builder.Property(oi => oi.OrderId).IsRequired(); builder.Property(oi => oi.AuthorBookId).IsRequired(); builder.Property(oi => oi.ProductPriceId).IsRequired(); builder.Property(oi => oi.Quantity).IsRequired(); builder.HasOne(oi => oi.Order) .WithMany(o => o.OrderItems) .HasForeignKey(oi => oi.OrderId) .OnDelete(DeleteBehavior.Cascade); builder.HasOne(oi => oi.AuthorBook) .WithMany() .HasForeignKey(oi => oi.AuthorBookId) .OnDelete(DeleteBehavior.Restrict); builder.HasOne(oi => oi.ProductPrice) .WithMany() .HasForeignKey(oi => oi.ProductPriceId) .OnDelete(DeleteBehavior.Restrict); } }