Files
Backend-Api/AccountMangement.Infrastructure.EFCore/Mappings/SubAccountMapping.cs
2025-01-06 23:14:03 +03:30

31 lines
1.4 KiB
C#

using _0_Framework.Application;
using AccountManagement.Domain.SubAccountAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
namespace AccountMangement.Infrastructure.EFCore.Mappings
{
public class SubAccountMapping : IEntityTypeConfiguration<SubAccount>
{
public void Configure(EntityTypeBuilder<SubAccount> builder)
{
builder.ToTable("SubAccounts");
builder.HasKey(x => x.id);
builder.Property(x => x.IsActive).HasConversion(x => x.ToString()
, x => ((IsActive)Enum.Parse(typeof(IsActive), x))).HasMaxLength(5);
builder.Property(x => x.PhoneNumber).HasMaxLength(11).IsRequired();
builder.Ignore(x => x.FullName);
builder.Property(x => x.Username).HasMaxLength(100).IsRequired();
builder.Property(x => x.Password).HasMaxLength(1000).IsRequired();
builder.Property(x => x.VerifyCode).HasMaxLength(10);
builder.Property(x => x.NationalCode).HasMaxLength(10);
builder.Property(x => x.FName).HasMaxLength(50);
builder.Property(x => x.LName).HasMaxLength(50);
builder.Property(x => x.ProfilePhoto).HasMaxLength(500).IsRequired(false);
builder.Property(x => x.SubAccountRoleId);
builder.HasOne(x => x.SubAccountRole).WithMany(x => x.SubAccounts).HasForeignKey(x => x.SubAccountRoleId);
}
}
}