using System;
using System.Collections.Generic;
using EVCB_OCPP.Domain.Models.ConnectionLogDB;
using Microsoft.EntityFrameworkCore;

namespace EVCB_OCPP.Domain;

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

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

    public virtual DbSet<MachineConnectionLog> MachineConnectionLogs { get; set; }

    public virtual DbSet<MigrationHistory> MigrationHistories { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.UseCollation("Chinese_Taiwan_Stroke_CI_AS");

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

            entity.ToTable("MachineConnectionLog");

            entity.Property(e => e.ChargeBoxId).HasMaxLength(128);
            entity.Property(e => e.CreatedOn).HasColumnType("datetime");
            entity.Property(e => e.Data).HasMaxLength(3600);
            entity.Property(e => e.EvseendPoint)
                .HasMaxLength(25)
                .HasColumnName("EVSEEndPoint");
            entity.Property(e => e.MessageType).HasMaxLength(50);
            entity.Property(e => e.Msg).HasMaxLength(200);
            entity.Property(e => e.Session).HasMaxLength(36);
        });


        modelBuilder.Entity<MigrationHistory>(entity =>
        {
            entity.HasKey(e => new { e.MigrationId, e.ContextKey }).HasName("PK_dbo.__MigrationHistory");

            entity.ToTable("__MigrationHistory");

            entity.Property(e => e.MigrationId).HasMaxLength(150);
            entity.Property(e => e.ContextKey).HasMaxLength(300);
            entity.Property(e => e.Model).IsRequired();
            entity.Property(e => e.ProductVersion)
                .IsRequired()
                .HasMaxLength(32);
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}