using Lada.Framework.Data.Domains.Trucks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Lada.Framework.Data.Mappings.EntityMappings.Trucks
{
    public class TruckMaintLinkMap : IEntityMappingConfiguration<TruckMaintLink>
    {
        public void Map(EntityTypeBuilder<TruckMaintLink> builder)
        {
            builder.HasKey(o => o.Id);
            builder.HasOne(o => o.TruckMaintenance).WithMany(o => o.TruckMaintLinks).HasForeignKey(x => x.TruckMaintenanceId).IsRequired();
            builder.HasOne(o => o.TruckMaintAttribute).WithMany(o => o.TruckMaintLinks).HasForeignKey(x => x.TruckMaintAttributeId).IsRequired();

            builder.ToTable("TruckMaintLink");
        }
    }
}
