Files
2026-07-21 14:08:10 +07:00

27 lines
1.1 KiB
C#

using Indotalent.Data.Entities;
using Indotalent.Shared.Consts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Indotalent.Infrastructure.Database.MsSQL.Configuration;
public class PromotionConfiguration : IEntityTypeConfiguration<Promotion>
{
public void Configure(EntityTypeBuilder<Promotion> builder)
{
builder.Property(p => p.AutoNumber).HasMaxLength(GlobalConsts.StringLengthShort);
builder.Property(p => p.EmployeeId).HasMaxLength(GlobalConsts.StringLengthId);
builder.Property(p => p.FromGrade).HasMaxLength(GlobalConsts.StringLengthShort);
builder.Property(p => p.ToGrade).HasMaxLength(GlobalConsts.StringLengthShort);
builder.Property(p => p.PromotionNote).HasMaxLength(GlobalConsts.StringLengthMedium);
builder.Property(p => p.Status).HasMaxLength(GlobalConsts.StringLengthShort);
builder.HasIndex(p => p.AutoNumber).IsUnique();
builder.HasIndex(p => p.EmployeeId);
builder.HasOne(p => p.Employee)
.WithMany()
.HasForeignKey(p => p.EmployeeId)
.OnDelete(DeleteBehavior.NoAction);
}
}