using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace FaultMapDev.EFModels
{
    public partial class QM_AthenaContext : DbContext
    {
        public QM_AthenaContext()
        {
        }

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

        public virtual DbSet<ObjTelematicFault> ObjTelematicFaults { get; set; }
        public virtual DbSet<ObjTelematicFault1> ObjTelematicFaults1 { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#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 http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Server=QTNABDDCW595; Database=QM_Athena; user=QM_Athena_Appl;password=Quality150715;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");

            modelBuilder.Entity<ObjTelematicFault>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("OBJ_TELEMATIC_FAULTS", "Hold");

                entity.Property(e => e.EcuName).HasMaxLength(4000);

                entity.Property(e => e.EventDate)
                    .HasColumnType("datetime")
                    .HasColumnName("EVENT_DATE");

                entity.Property(e => e.EventId)
                    .HasMaxLength(4000)
                    .HasColumnName("EVENT_ID");

                entity.Property(e => e.FaultCode)
                    .HasMaxLength(4000)
                    .HasColumnName("FAULT_CODE");

                entity.Property(e => e.Fmi)
                    .HasMaxLength(4000)
                    .HasColumnName("FMI");

                entity.Property(e => e.FmiText).HasMaxLength(4000);

                entity.Property(e => e.Latitude).HasMaxLength(4000);

                entity.Property(e => e.Longitude).HasMaxLength(4000);

                entity.Property(e => e.Odometer).HasMaxLength(4000);

                entity.Property(e => e.Sa).HasMaxLength(4000);

                entity.Property(e => e.Spn)
                    .HasMaxLength(4000)
                    .HasColumnName("SPN");

                entity.Property(e => e.SpnText).HasMaxLength(4000);

                entity.Property(e => e.Vin)
                    .HasMaxLength(4000)
                    .HasColumnName("VIN");
            });

            modelBuilder.Entity<ObjTelematicFault1>(entity =>
            {
                entity.HasKey(e => e.EventId)
                    .HasName("PK_OBJ_TELEMATIC_FAULTS_NEW");

                entity.ToTable("OBJ_TELEMATIC_FAULTS", "OBJ");

                entity.Property(e => e.EventId)
                    .HasMaxLength(100)
                    .HasColumnName("EVENT_ID");

                entity.Property(e => e.EcuName).HasMaxLength(15);

                entity.Property(e => e.EventDate).HasColumnName("EVENT_DATE");

                entity.Property(e => e.FaultCode)
                    .IsRequired()
                    .HasMaxLength(20)
                    .HasColumnName("FAULT_CODE");

                entity.Property(e => e.Fmi)
                    .HasMaxLength(10)
                    .HasColumnName("FMI");

                entity.Property(e => e.FmiText).HasMaxLength(500);

                entity.Property(e => e.GeoFence)
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("GEO_FENCE");

                entity.Property(e => e.InvalidDate).HasColumnName("INVALID_DATE");

                entity.Property(e => e.InvalidGps).HasColumnName("INVALID_GPS");

                entity.Property(e => e.Latitude).HasMaxLength(100);

                entity.Property(e => e.Longitude).HasMaxLength(100);

                entity.Property(e => e.MileageImplausible).HasColumnName("MILEAGE_IMPLAUSIBLE");

                entity.Property(e => e.Odometer).HasMaxLength(20);

                entity.Property(e => e.Sa).HasMaxLength(3);

                entity.Property(e => e.Spn)
                    .HasMaxLength(10)
                    .HasColumnName("SPN");

                entity.Property(e => e.SpnText).HasMaxLength(500);

                entity.Property(e => e.Vin)
                    .IsRequired()
                    .HasMaxLength(17)
                    .HasColumnName("VIN");

                entity.Property(e => e.WeatherParsed).HasColumnName("WEATHER_PARSED");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
