41 lines
1.4 KiB
C#
41 lines
1.4 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 EmployeeDeductionConfiguration : IEntityTypeConfiguration<EmployeeDeduction>
|
|
{
|
|
public void Configure(EntityTypeBuilder<EmployeeDeduction> builder)
|
|
{
|
|
builder.Property(e => e.AutoNumber)
|
|
.HasMaxLength(GlobalConsts.StringLengthShort);
|
|
|
|
builder.Property(e => e.EmployeeId)
|
|
.HasMaxLength(GlobalConsts.StringLengthId);
|
|
|
|
builder.Property(e => e.DeductionId)
|
|
.HasMaxLength(GlobalConsts.StringLengthId);
|
|
|
|
builder.Property(e => e.Description)
|
|
.HasMaxLength(GlobalConsts.StringLengthShort);
|
|
|
|
builder.Property(e => e.Amount)
|
|
.HasPrecision(18, 2);
|
|
|
|
builder.HasIndex(e => new { e.TenantId, e.AutoNumber }).IsUnique();
|
|
builder.HasIndex(e => e.EmployeeId);
|
|
builder.HasIndex(e => e.DeductionId);
|
|
|
|
builder.HasOne(e => e.Employee)
|
|
.WithMany(p => p.EmployeeDeduction)
|
|
.HasForeignKey(e => e.EmployeeId)
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
|
|
builder.HasOne(e => e.Deduction)
|
|
.WithMany()
|
|
.HasForeignKey(e => e.DeductionId)
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
}
|
|
} |