using LiteCharms.Features.Shop.Products.Entities; namespace LiteCharms.Features.Shop.ShoppingCarts.Entities; public class ShoppingCartItemConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("ShoppingCartItems"); builder.HasKey(f => f.Id); builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()"); builder.Property(f => f.UpdatedAt).IsRequired(false).HasDefaultValueSql(null); builder.Property(f => f.Quantity).IsRequired().HasDefaultValue(1); builder.Property(f => f.ShoppingCartId).IsRequired(); builder.Property(f => f.ProductPriceId).IsRequired(); builder.HasOne() .WithMany(s => s.ShoppingCartItems) .HasForeignKey(f => f.ShoppingCartId) .IsRequired() .OnDelete(DeleteBehavior.Cascade); builder.HasOne() .WithMany() .HasForeignKey(f => f.ProductPriceId) .IsRequired() .OnDelete(DeleteBehavior.Restrict); } }