using APT.Infrastructure.EF.Map;
using APT.BaseData.Domain.Entities.FM;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;

namespace APT.BaseData.Data.Mapping.FM
{
	public class FMCalendarMap : APTEntityBaseMap<T_FM_CALENDAR>
    {
		public override void Configure(EntityTypeBuilder<T_FM_CALENDAR> builder)
		{
			base.Configure(builder);

			// Properties
			builder.Property(t => t.NAME).HasMaxLength(50);
			builder.Property(t => t.CODE).HasMaxLength(50);
            builder.Property(t => t.NAME_ACRONYM).HasMaxLength(100);
            //relation
            builder.HasMany(t => t.Nav_CalendarClass).WithOne().HasForeignKey(t => t.CALENDAR_ID).OnDelete(DeleteBehavior.Restrict);
			builder.HasOne(t => t.Nav_Holiday).WithMany().HasForeignKey(t => t.HOLIDAY_ID).OnDelete(DeleteBehavior.Restrict);
		} 
    }
}
