using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using NetworkResurrector.Api.Domain.Entities.Security;

namespace NetworkResurrector.Api.Domain.Data.EntityTypeConfiguration.Security
{
    class PermissionHierarchyConfiguration : IEntityTypeConfiguration<PermissionHierarchy>
    {
        public void Configure(EntityTypeBuilder<PermissionHierarchy> builder)
        {
            builder.ToTable("PermissionHierarchy").HasKey(p => new { p.ParentPermissionId, p.ChildPermissionId });
            builder.HasOne(z => z.Child).WithMany().HasForeignKey(p => p.ChildPermissionId);
        }
    }
}
