Files
components/LiteCharms.Features/Shop/ShoppingCarts/Entities/ShoppingCartPackageConfiguration.cs
T
2026-05-13 20:06:24 +02:00

27 lines
997 B
C#

namespace LiteCharms.Features.Shop.ShoppingCarts.Entities;
public class ShoppingCartPackageConfiguration : IEntityTypeConfiguration<ShoppingCartPackage>
{
public void Configure(EntityTypeBuilder<ShoppingCartPackage> builder)
{
builder.ToTable(nameof(ShoppingCartPackage));
builder.HasKey(f => f.Id);
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
builder.Property(f => f.ShoppingCartId).IsRequired();
builder.Property(f => f.PackageId).IsRequired();
builder.HasOne(f => f.ShoppingCart)
.WithMany(s => s.ShoppingCartPackages)
.HasForeignKey(scp => scp.ShoppingCartId)
.IsRequired()
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(f => f.Package)
.WithMany()
.HasForeignKey(scp => scp.PackageId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
}
}