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

namespace APT.BaseData.Data.Mapping.FM
{
	public class FMProductProcessDetailMap : APTEntityBaseMap<T_FM_PRODUCT_PROCESS_DETAIL>
    {
		public override void Configure(EntityTypeBuilder<T_FM_PRODUCT_PROCESS_DETAIL> builder)
		{
			base.Configure(builder); builder.Property(t => t.ORDER_FIELD).HasMaxLength(100);
			builder.Property(t => t.NAME).HasMaxLength(100);
            builder.Property(t => t.NAME_ACRONYM).HasMaxLength(200);
            builder.Property(t => t.REMARK).HasMaxLength(500);
			builder.HasOne(t => t.Nav_Unit).WithMany().HasForeignKey(t => t.UNIT_ID);
			builder.HasOne(t => t.Nav_Parent).WithMany().HasForeignKey(t => t.PARENT_ID);

			builder.HasOne(t => t.Nav_Procedure).WithMany().HasForeignKey(t => t.PROCEDURE_ID);

			builder.HasOne(t => t.Nav_Product_Process).WithMany(t => t.Nav_Details).HasForeignKey(t => t.PRODUCT_PROCESS_ID);//主从表绑定

			builder.HasOne(t => t.Nav_PQCWorkStage).WithMany().HasForeignKey(t => t.PQC_WORKSTAGE_ID);

			builder.Property(t => t.EXT_PROCEDURE_CODE).HasMaxLength(200);
			builder.HasOne(t => t.Nav_ProcessDetail).
			WithMany().HasForeignKey(t => t.PROCESS_DETAIL_ID);
		} 
    }
}
