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

namespace EVCB_OCPP.Domain;

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

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

    public virtual DbSet<ConnectorMeterValueRecord> ConnectorMeterValueRecords { get; set; }

    public virtual DbSet<MigrationHistory> MigrationHistories { get; set; }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.UseCollation("Chinese_Taiwan_Stroke_CI_AS");

        modelBuilder.Entity<ConnectorMeterValueRecord>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("ConnectorMeterValueRecord");

            entity.Property(e => e.ChargeBoxId).HasMaxLength(50);
            entity.Property(e => e.CreatedOn).HasColumnType("smalldatetime");
            entity.Property(e => e.Value).HasMaxLength(10);
        });

        modelBuilder.Entity<MigrationHistory>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("__MigrationHistory");

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

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
