This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
namespace LiteCharms.Features.TechShop.ShoppingCarts.Entities;
|
||||
|
||||
public class ShoppingCartPackageConfiguration : IEntityTypeConfiguration<ShoppingCartPackage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ShoppingCartPackage> builder)
|
||||
{
|
||||
builder.ToTable("ShoppingCartPackages");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user