26 lines
1.2 KiB
C#
26 lines
1.2 KiB
C#
using static PostFundManagement.Domain.Extensions.Constants;
|
|
|
|
namespace PostFundManagement.Domain.Configuration.Entities;
|
|
|
|
public sealed class Organisation : IEntityTypeConfiguration<Domain.Entities.Organisation>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Domain.Entities.Organisation> builder)
|
|
{
|
|
builder.ToTable(nameof(Domain.Entities.Organisation).Pluralize());
|
|
|
|
builder.HasKey(pk => pk.Id);
|
|
builder.Property(f => f.CreatedBy).IsRequired();
|
|
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
|
builder.Property(f => f.RegistrationNo).IsRequired().HasMaxLength(LabelLength);
|
|
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
|
|
builder.Property(f => f.Email).IsRequired().HasMaxLength(LabelLength);
|
|
builder.Property(f => f.Type).IsRequired().HasConversion<int>().HasDefaultValueSql("5");
|
|
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1");
|
|
|
|
builder.HasOne(f => f.Creator)
|
|
.WithMany()
|
|
.HasForeignKey(fk => fk.CreatedBy)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
}
|
|
} |