using FindAndDrive.Domain.Models.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace FindAndDrive.Persistence.EntityConfigurations { public class ApplicantConfiguration: IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(k => k.ApplicantId); builder.HasOne(x => x.ApplicantFinance).WithOne(x => x.Applicant); builder.HasOne(x => x.ApplicantAuditLog).WithOne(x => x.Applicant); builder.HasOne(x => x.ApplicantCredit).WithOne(x => x.Applicant); builder.HasOne(x => x.ApplicantFraudAlert).WithOne(x => x.Applicant); builder.HasOne(x => x.ApplicantPredicition).WithOne(x => x.Applicant); //Configure Enum Mapping builder.Property(d => d.Province).HasConversion().HasMaxLength(13); builder.Property(d => d.MaritalStatus).HasConversion().HasMaxLength(10); builder.Property(p => p.Gender).HasConversion().HasMaxLength(10); //Not necassary to specify all collumns, collumns taken from models //Specify max length on string fields only builder.Property(p => p.Title).HasMaxLength(5); builder.Property(p => p.FirstName).HasMaxLength(50); builder.Property(p => p.LastName).HasMaxLength(50); builder.Property(p => p.IdNumber).HasMaxLength(20); builder.Property(p => p.MobileNumber).HasMaxLength(20); builder.Property(p => p.EmailAddress).HasMaxLength(255); builder.Property(p => p.SpouseName).HasMaxLength(50); builder.Property(p => p.AddressLine1).HasMaxLength(50); builder.Property(p => p.AddressLine2).HasMaxLength(50); builder.Property(p => p.Suburb).HasMaxLength(50); builder.Property(p => p.City).HasMaxLength(50); builder.Property(p => p.PostalCode).HasMaxLength(12); builder.Property(p => p.ResidentialStatus).HasMaxLength(50); builder.Property(p => p.AddressDate).HasMaxLength(50); } } }