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 UserInfoMap : IEntityTypeConfiguration<UserInfo>
    {
        public void Configure(EntityTypeBuilder<UserInfo> entity)
        {
            entity.ToTable("user_info");

            entity.HasIndex(e => e.BusinessUnitInfoId)
                .HasName("user_info_bu_id");

            entity.HasIndex(e => e.Id)
                .HasName("user_info_id");

            entity.HasIndex(e => new { e.BusinessUnitInfoId, e.PhoneNo })
                .HasName("user_info_bu_id_phone_no");

            entity.HasIndex(e => new { e.BusinessUnitInfoId, e.UserName })
                .HasName("user_info_bu_id_user_name");

            entity.HasIndex(e => new { e.BusinessUnitInfoId, e.UserNo })
                .HasName("user_info_bu_id_user_no");

            entity.Property(e => e.Id)
                .HasColumnName("id")
                .ValueGeneratedNever();

            entity.Property(e => e.Address)
                .HasColumnName("address")
                .HasMaxLength(255);

            entity.Property(e => e.AliPayId)
                .HasColumnName("ali_pay_id")
                .HasMaxLength(255);

            entity.Property(e => e.Amount).HasColumnName("amount");

            entity.Property(e => e.Birthday).HasColumnName("birthday");

            entity.Property(e => e.BuId)
                .HasColumnName("bu_id")
                .HasMaxLength(255);

            entity.Property(e => e.BuString)
                .HasColumnName("bu_string")
                .HasMaxLength(255);

            entity.Property(e => e.BusinessUnitInfoId).HasColumnName("business_unit_info_id");

            entity.Property(e => e.CertificateNo)
                .HasColumnName("certificate_no")
                .HasMaxLength(255);

            entity.Property(e => e.CertificateType)
                .HasColumnName("certificate_type")
                .HasMaxLength(255);

            entity.Property(e => e.CreationDate).HasColumnName("creation_date");

            entity.Property(e => e.EnableSms).HasColumnName("enable_sms");

            entity.Property(e => e.FuelNo)
                .HasColumnName("fuel_no")
                .HasMaxLength(255);

            entity.Property(e => e.Gender)
                .HasColumnName("gender")
                .HasMaxLength(255);

            entity.Property(e => e.Gift).HasColumnName("gift");

            entity.Property(e => e.InvoiceBalance).HasColumnName("invoice_balance");

            entity.Property(e => e.LastActiveDate).HasColumnName("last_active_date");

            entity.Property(e => e.LastLevelUpTime).HasColumnName("last_level_up_time");

            entity.Property(e => e.LastMembershipLevel).HasColumnName("last_membership_level");

            entity.Property(e => e.MembershipLevel).HasColumnName("membership_level");

            entity.Property(e => e.MembershipPoints)
                .HasColumnName("membership_points")
                .HasMaxLength(255);

            entity.Property(e => e.NextLevelUpDateTime).HasColumnName("next_level_up_date_time");

            entity.Property(e => e.OfflineTransferRemaining).HasColumnName("offline_transfer_remaining");

            entity.Property(e => e.PassCode)
                .HasColumnName("pass_code")
                .HasMaxLength(255);

            entity.Property(e => e.Password)
                .HasColumnName("password")
                .HasMaxLength(255);

            entity.Property(e => e.PhoneNo)
                .HasColumnName("phone_no")
                .HasMaxLength(255);

            entity.Property(e => e.Portrait)
                .HasColumnName("portrait")
                .HasMaxLength(255);

            entity.Property(e => e.RechargeTotal).HasColumnName("recharge_total");

            entity.Property(e => e.TotalSpending)
                .HasColumnName("total_spending")
                .HasDefaultValueSql("0");

            entity.Property(e => e.TotalVolume)
                .HasColumnName("total_volume")
                .HasDefaultValueSql("0");

            entity.Property(e => e.UnionId)
                .HasColumnName("union_id")
                .HasMaxLength(255);

            entity.Property(e => e.UserId).HasColumnName("user_id");

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

            entity.Property(e => e.UserName)
                .HasColumnName("user_name")
                .HasMaxLength(255);

            entity.Property(e => e.UserNo)
                .HasColumnName("user_no")
                .HasMaxLength(255);

            entity.Property(e => e.UserState).HasColumnName("user_state");

            entity.Property(e => e.UserType).HasColumnName("user_type");

            entity.Property(e => e.VehicleLicenseNo)
                .HasColumnName("vehicle_license_no")
                .HasMaxLength(255);

            entity.Property(e => e.VehicleModel)
                .HasColumnName("vehicle_model")
                .HasMaxLength(255);

            entity.HasOne(d => d.BusinessUnitInfo)
                .WithMany(p => p.UserInfo)
                .HasForeignKey(d => d.BusinessUnitInfoId)
                .HasConstraintName("fksxb41p6dxyhjqm7r10vlxfd6g");

            entity.HasOne(d => d.LastMembershipLevelNavigation)
                .WithMany(p => p.UserInfoLastMembershipLevelNavigation)
                .HasForeignKey(d => d.LastMembershipLevel)
                .HasConstraintName("user_info_last_membership_level_fkey");

            entity.HasOne(d => d.MembershipLevelNavigation)
                .WithMany(p => p.UserInfoMembershipLevelNavigation)
                .HasForeignKey(d => d.MembershipLevel)
                .HasConstraintName("user_info_membership_level_fkey");

            entity.HasOne(d => d.UserInfoNavigation)
                .WithMany(p => p.InverseUserInfoNavigation)
                .HasForeignKey(d => d.UserInfoId)
                .HasConstraintName("fk5ua5b6b1a136mgeuapq75epg");
        }
    }
}
