using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal;

namespace BLW_Log.Models;

public partial class LowmachinelogContext : DbContext
{
    public LowmachinelogContext()
    {
    }

    public LowmachinelogContext(DbContextOptions<LowmachinelogContext> options)
        : base(options)
    {
    }

    public virtual DbSet<DevMonitorlog> DevMonitorlogs { get; set; }

    public virtual DbSet<Excelgenerater> Excelgeneraters { get; set; }

    public virtual DbSet<IotMonitorlog> IotMonitorlogs { get; set; }

    public virtual DbSet<Recordhotel> Recordhotels { get; set; }

    public virtual DbSet<StatisticsTotal> StatisticsTotals { get; set; }

    public virtual DbSet<WebapiMonitorlog> WebapiMonitorlogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseMySql("server=10.8.8.212;database=lowmachinelog;charset=utf8;uid=BLWlog;pwd=Blw@1234;port=16036", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.40-mysql"));

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_0900_ai_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<DevMonitorlog>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("dev_monitorlog");

            entity.HasIndex(e => e.CommandType, "CommandType");

            entity.HasIndex(e => e.CreateTimeToUnixTime, "CreateTIme");

            entity.HasIndex(e => new { e.HotelCode, e.HostNumber, e.HostId, e.RoomNo }, "MAC");

            entity.HasIndex(e => e.Mac, "MM");

            entity.HasIndex(e => e.CreateTime, "T");

            entity.Property(e => e.Id).HasColumnName("ID");
            entity.Property(e => e.AnalysisData).HasColumnType("text");
            entity.Property(e => e.CommandType).HasMaxLength(128);
            entity.Property(e => e.CreateTime).HasMaxLength(64);
            entity.Property(e => e.Data).HasColumnType("text");
            entity.Property(e => e.HostId).HasColumnName("HostID");
            entity.Property(e => e.HostNumber).HasMaxLength(64);
            entity.Property(e => e.HotelCode).HasMaxLength(64);
            entity.Property(e => e.HotelId).HasColumnName("HotelID");
            entity.Property(e => e.LanIp)
                .HasMaxLength(64)
                .HasColumnName("LanIP");
            entity.Property(e => e.Mac)
                .HasMaxLength(64)
                .HasColumnName("MAC");
            entity.Property(e => e.RoomNo).HasMaxLength(64);
            entity.Property(e => e.SendOrReceive).HasMaxLength(64);
            entity.Property(e => e.WwwIp)
                .HasMaxLength(64)
                .HasColumnName("WWW_IP");
            entity.Property(e => e.WwwPort).HasColumnName("WWW_Port");
        });

        modelBuilder.Entity<Excelgenerater>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("excelgenerater");

            entity.Property(e => e.Id)
                .ValueGeneratedNever()
                .HasColumnName("ID");
            entity.Property(e => e.CreateTime).HasColumnType("datetime");
            entity.Property(e => e.CreateTimeUnix).HasColumnName("CreateTime_UNIX");
            entity.Property(e => e.StepInfo).HasColumnType("text");
        });

        modelBuilder.Entity<IotMonitorlog>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("iot_monitorlog");

            entity.Property(e => e.Id).HasColumnName("ID");
            entity.Property(e => e.CommandDescription).HasColumnType("text");
            entity.Property(e => e.HotelCode).HasMaxLength(255);
            entity.Property(e => e.HotelName).HasMaxLength(255);
            entity.Property(e => e.Platform).HasMaxLength(128);
            entity.Property(e => e.RequestId).HasMaxLength(512);
            entity.Property(e => e.RoomNumber).HasMaxLength(255);
            entity.Property(e => e.TriggerTime).HasMaxLength(64);
        });

        modelBuilder.Entity<Recordhotel>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("recordhotel");

            entity.Property(e => e.Id).HasColumnName("ID");
            entity.Property(e => e.CreateTime).HasMaxLength(64);
            entity.Property(e => e.HotelId).HasColumnName("HotelID");
        });

        modelBuilder.Entity<StatisticsTotal>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("statistics_total");

            entity.Property(e => e.Id).HasColumnName("ID");
            entity.Property(e => e.HostNumber).HasMaxLength(64);
            entity.Property(e => e.HotelCode).HasMaxLength(64);
            entity.Property(e => e.Mac)
                .HasMaxLength(64)
                .HasColumnName("MAC");
            entity.Property(e => e.RxCount).HasColumnName("RX_Count");
            entity.Property(e => e.TxCount).HasColumnName("TX_Count");
            entity.Property(e => e.UpdateTime)
                .HasMaxLength(64)
                .HasColumnName("Update_Time");
        });

        modelBuilder.Entity<WebapiMonitorlog>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("webapi_monitorlog");

            entity.HasIndex(e => e.MethodName, "MethodName");

            entity.HasIndex(e => new { e.InvokStartTime, e.InvokEndTime }, "Time");

            entity.Property(e => e.Id).HasColumnName("ID");
            entity.Property(e => e.HotelCode).HasMaxLength(64);
            entity.Property(e => e.InvokEndTime)
                .HasMaxLength(64)
                .HasColumnName("InvokEnd_Time");
            entity.Property(e => e.InvokStartTime)
                .HasMaxLength(64)
                .HasColumnName("InvokStart_Time");
            entity.Property(e => e.MethodName).HasMaxLength(128);
            entity.Property(e => e.Parameters).HasColumnType("text");
            entity.Property(e => e.RemoteIp)
                .HasMaxLength(64)
                .HasColumnName("RemoteIP");
            entity.Property(e => e.RoomNumber).HasMaxLength(64);
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
