Files
Backend-Api/CompanyManagment.EFCore/Mapping/AuthorizedPersonMapping.cs

61 lines
1.7 KiB
C#

using Company.Domain.AuthorizedPersonAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class AuthorizedPersonMapping : IEntityTypeConfiguration<AuthorizedPerson>
{
public void Configure(EntityTypeBuilder<AuthorizedPerson> builder)
{
builder.ToTable("AuthorizedPersons");
builder.HasKey(x => x.id);
builder.Property(x => x.NationalCode)
.HasMaxLength(10)
.IsRequired();
builder.Property(x => x.FirstName)
.HasMaxLength(100)
.IsRequired();
builder.Property(x => x.LastName)
.HasMaxLength(100)
.IsRequired();
builder.Property(x => x.FatherName)
.HasMaxLength(100);
builder.Property(x => x.BirthDate)
.HasMaxLength(10);
builder.Property(x => x.Gender)
.HasMaxLength(50);
builder.Property(x => x.DeathStatus)
.HasMaxLength(50);
builder.Property(x => x.ShenasnameSeri)
.HasMaxLength(10);
builder.Property(x => x.ShenasnameSerial)
.HasMaxLength(10);
builder.Property(x => x.ShenasnamehNumber)
.HasMaxLength(20);
builder.Property(x => x.IsVerified)
.IsRequired();
builder.Property(x => x.VerificationDate);
builder.Property(x => x.CreationDate)
.IsRequired();
// Index for better performance on NationalCode queries
builder.HasIndex(x => x.NationalCode)
.IsUnique();
}
}