Files
components/LiteCharms.Features.TechShop/CartPackages/Entities/PackageItemConfiguration.cs
T
Khwezi Mngoma 70c6e0bfbc
continuous-integration/drone/pr Build is passing
Split Features to create space for more projects
2026-05-24 13:19:09 +02:00

28 lines
985 B
C#

namespace LiteCharms.Features.TechShop.CartPackages.Entities;
public class PackageItemConfiguration : IEntityTypeConfiguration<PackageItem>
{
public void Configure(EntityTypeBuilder<PackageItem> builder)
{
builder.ToTable(nameof(PackageItem));
builder.HasKey(f => f.Id);
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
builder.Property(f => f.PackageId).IsRequired();
builder.Property(f => f.ProductPriceId).IsRequired();
builder.Property(f => f.Active);
builder.HasOne(f => f.Package)
.WithMany(f => f.PackageItems)
.HasForeignKey(pi => pi.PackageId)
.IsRequired()
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(f => f.ProductPrice)
.WithMany()
.HasForeignKey(pi => pi.ProductPriceId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
}
}