38 lines
1.8 KiB
C#
38 lines
1.8 KiB
C#
using AccountManagement.Domain.AccountAgg;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace AccountMangement.Infrastructure.EFCore.Mappings;
|
|
|
|
public class AccountMapping : IEntityTypeConfiguration<Account>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Account> builder)
|
|
{
|
|
builder.ToTable("Accounts");
|
|
builder.HasKey(x => x.id);
|
|
|
|
builder.Property(x => x.Fullname).HasMaxLength(100).IsRequired();
|
|
builder.Property(x => x.Username).HasMaxLength(100).IsRequired();
|
|
builder.Property(x => x.Password).HasMaxLength(1000).IsRequired();
|
|
builder.Property(x => x.ProfilePhoto).HasMaxLength(500).IsRequired(false);
|
|
builder.Property(x => x.Mobile).HasMaxLength(20).IsRequired();
|
|
builder.Property(x => x.RoleName).HasMaxLength(100);
|
|
builder.Property(x => x.AdminAreaPermission).HasMaxLength(10);
|
|
builder.Property(x => x.ClientAriaPermission).HasMaxLength(10);
|
|
builder.Property(x => x.NationalCode).HasMaxLength(10);
|
|
builder.Property(x => x.Email).HasMaxLength(150);
|
|
builder.Property(x => x.VerifyCode).HasMaxLength(1000);
|
|
builder.Property(x => x.IsActiveString).HasMaxLength(6);
|
|
builder.Property(x => x.PositionId).HasMaxLength(10).IsRequired(false);
|
|
builder.Property(x => x.PositionIsActive).HasMaxLength(5);
|
|
|
|
builder.HasOne(x => x.Role).WithMany(x => x.Accounts).HasForeignKey(x => x.RoleId);
|
|
builder.HasMany(x => x.CameraAccounts)
|
|
.WithOne(x => x.Account)
|
|
.HasForeignKey(x => x.AccountId);
|
|
builder.HasOne(x => x.Position).WithMany(x => x.Accounts).HasForeignKey(x => x.PositionId).IsRequired(false);
|
|
builder.HasMany(x => x.AccountLeftWorkList)
|
|
.WithOne(x => x.Account)
|
|
.HasForeignKey(x => x.AccountId);
|
|
}
|
|
} |