Files
components/LiteCharms.Features.MidrandBooks/Customers/Entities/ContactConfiguration.cs
T
Khwezi Mngoma 902942eee6
continuous-integration/drone/pr Build is passing
Completed initial database design
Sealed qualifying public classes
Migrated database changes
2026-05-27 09:12:04 +02:00

27 lines
1.1 KiB
C#

namespace LiteCharms.Features.MidrandBooks.Customers.Entities;
public sealed class ContactConfiguration : IEntityTypeConfiguration<Contact>
{
public void Configure(EntityTypeBuilder<Contact> builder)
{
builder.ToTable("Contacts");
builder.HasKey(c => c.Id);
builder.Property(c => c.CustomerId).IsRequired();
builder.Property(c => c.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
builder.Property(c => c.UpdatedAt).HasDefaultValueSql("now()");
builder.Property(c => c.Name).IsRequired();
builder.Property(c => c.LastName).IsRequired();
builder.Property(c => c.Type).IsRequired();
builder.Property(c => c.Phone).IsRequired();
builder.Property(c => c.Email).IsRequired();
builder.Property(c => c.IsPrimary).HasDefaultValue(false);
builder.Property(c => c.Enabled).HasDefaultValue(true);
builder.HasOne(c => c.Customer)
.WithMany(c => c.Contacts)
.HasForeignKey(c => c.CustomerId)
.OnDelete(DeleteBehavior.Cascade);
}
}