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

namespace NetworkResurrector.Api.Domain.Data.EntityTypeConfiguration.Security
{
    class PermissionConfiguration : IEntityTypeConfiguration<Permission>
    {
        public void Configure(EntityTypeBuilder<Permission> builder)
        {
            builder.ToTable("Permission").HasKey(key => key.PermissionId);
            builder.Property(z => z.PermissionId).ValueGeneratedOnAdd();
            builder.HasMany(z => z.Children).WithOne().HasForeignKey(z => z.ParentPermissionId);
        }
    }
}
