902942eee6
continuous-integration/drone/pr Build is passing
Sealed qualifying public classes Migrated database changes
27 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|