using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using MS.Entities.AccountingService_Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace MS.DbContexts.AccountingService
{
    public class UserInfoMembershipGroupsMap : IEntityTypeConfiguration<UserInfoMembershipGroups>
    {
        public void Configure(EntityTypeBuilder<UserInfoMembershipGroups> entity)
        {
            entity.HasKey(e => new { e.UserInfoId, e.MembershipGroupId })
    .HasName("user_info_membership_groups_pkey");

            entity.ToTable("user_info_membership_groups");

            entity.Property(e => e.UserInfoId).HasColumnName("user_info_id");

            entity.Property(e => e.MembershipGroupId).HasColumnName("membership_group_id");

            entity.HasOne(d => d.MembershipGroup)
                .WithMany(p => p.UserInfoMembershipGroups)
                .HasForeignKey(d => d.MembershipGroupId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("user_info_membership_groups_membership_group_id_fkey");

            entity.HasOne(d => d.UserInfo)
                .WithMany(p => p.UserInfoMembershipGroups)
                .HasForeignKey(d => d.UserInfoId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("user_info_membership_groups_user_info_id_fkey");
        }
    }
}
