using System; using System.Collections.Generic; using EVCB_OCPP.Domain.Models.MainDb; using Microsoft.EntityFrameworkCore; namespace EVCB_OCPP.Domain; public partial class MainDBContext : DbContext { public MainDBContext() { } public MainDBContext(DbContextOptions options) : base(options) { } public virtual DbSet ConnectorMeterValueRecords { get; set; } public virtual DbSet ConnectorStatuses { get; set; } public virtual DbSet Customers { get; set; } public virtual DbSet LoadingBalances { get; set; } public virtual DbSet Machines { get; set; } public virtual DbSet MachineConfigurations { get; set; } public virtual DbSet MachineErrors { get; set; } public virtual DbSet MachineOperateRecords { get; set; } public virtual DbSet MachineVersionFiles { get; set; } public virtual DbSet MigrationHistories { get; set; } public virtual DbSet Ocmfs { get; set; } public virtual DbSet ServerMessages { get; set; } public virtual DbSet TransactionRecords { get; set; } public virtual DbSet UploadFiles { get; set; } public virtual DbSet VConnectorStatuses { get; set; } public virtual DbSet VConnectorStatusCombinds { get; set; } public virtual DbSet VMachines { get; set; } public virtual DbSet VMachineCombinds { 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 http://go.microsoft.com/fwlink/?LinkId=723263. // => optionsBuilder.UseSqlServer("data source=zerova-ev-dev.database.windows.net;initial catalog=StandardOCPP_Main;persist security info=True;user id=azdevsoftware;password=1h52dev#az;MultipleActiveResultSets=True;App=EntityFramework"); protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.UseCollation("Chinese_Taiwan_Stroke_CI_AS"); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.ConnectorMeterValueRecord"); entity.ToTable("ConnectorMeterValueRecord"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.Value).HasMaxLength(10); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.ConnectorStatus"); entity.ToTable("ConnectorStatus"); entity.HasIndex(e => new { e.ChargeBoxId, e.ConnectorId }, "IX_ConnectorStatus").IsUnique(); entity.Property(e => e.Id).HasMaxLength(36); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.ErrorInfo).HasMaxLength(50); entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)"); entity.Property(e => e.VendorErrorCode).HasMaxLength(100); entity.Property(e => e.VendorId).HasMaxLength(255); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.Customer"); entity.ToTable("Customer"); entity.Property(e => e.Id).ValueGeneratedNever(); entity.Property(e => e.ApiCustomerId).HasMaxLength(36); entity.Property(e => e.ApiKey).HasMaxLength(128); entity.Property(e => e.ApiKeyUpdatedOn).HasColumnType("datetime"); entity.Property(e => e.ApiUrl).HasMaxLength(256); entity.Property(e => e.CreatedBy).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.Deadline).HasColumnType("datetime"); entity.Property(e => e.EnableTtia).HasColumnName("EnableTTIA"); entity.Property(e => e.Ftphost) .HasMaxLength(50) .HasColumnName("FTPHost"); entity.Property(e => e.Ftppassword) .HasMaxLength(20) .HasColumnName("FTPPassword"); entity.Property(e => e.Ftppath).HasColumnName("FTPPath"); entity.Property(e => e.Ftpuser) .HasMaxLength(20) .HasColumnName("FTPUser"); entity.Property(e => e.Name).HasMaxLength(50); entity.Property(e => e.PartnerId).HasMaxLength(36); entity.Property(e => e.TtiaApikey) .HasMaxLength(10) .HasColumnName("TTIA_APIKey"); entity.Property(e => e.TtiaApiurl) .HasMaxLength(100) .HasColumnName("TTIA_APIUrl"); entity.Property(e => e.TtiaCustomerId).HasColumnName("TTIA_CustomerId"); entity.Property(e => e.TtiaEquipmentProvider) .HasMaxLength(10) .HasColumnName("TTIA_EquipmentProvider"); entity.Property(e => e.UpdatedBy).HasMaxLength(50); entity.Property(e => e.UpdatedOn).HasColumnType("datetime"); }); modelBuilder.Entity(entity => { entity.ToTable("LoadingBalance"); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.FinishedOn).HasColumnType("datetime"); entity.Property(e => e.MachineId) .IsRequired() .HasMaxLength(36); entity.Property(e => e.Power).HasColumnType("decimal(10, 2)"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.Machine"); entity.ToTable("Machine"); entity.HasIndex(e => new { e.CustomerId, e.ChargeBoxId }, "nci_wi_Machine_7CD4A9D1688F96F6967B2244A0666F62"); entity.Property(e => e.Id).HasMaxLength(36); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.ChargeBoxSerialNumber).HasMaxLength(25); entity.Property(e => e.ChargePointModel).HasMaxLength(20); entity.Property(e => e.ChargePointSerialNumber).HasMaxLength(25); entity.Property(e => e.ChargePointVendor).HasMaxLength(20); entity.Property(e => e.Comment).HasMaxLength(100); entity.Property(e => e.ConnectorPowerType).HasMaxLength(50); entity.Property(e => e.ConnectorType).HasMaxLength(50); entity.Property(e => e.CreatedBy).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.FwAssignedVersion).HasColumnName("FW_AssignedVersion"); entity.Property(e => e.FwCurrentVersion) .HasMaxLength(50) .HasColumnName("FW_CurrentVersion"); entity.Property(e => e.FwVersionReport).HasColumnName("FW_VersionReport"); entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime"); entity.Property(e => e.Iccid).HasMaxLength(20); entity.Property(e => e.Imsi).HasMaxLength(20); entity.Property(e => e.Latitude).HasColumnType("decimal(10, 6)"); entity.Property(e => e.Longitude).HasColumnType("decimal(10, 6)"); entity.Property(e => e.MeterSerialNumber).HasMaxLength(25); entity.Property(e => e.MeterType).HasMaxLength(25); entity.Property(e => e.ModelName) .IsRequired() .HasMaxLength(50) .HasDefaultValueSql("('')"); entity.Property(e => e.OfflineOn).HasColumnType("datetime"); entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)"); entity.Property(e => e.Ttiatag).HasColumnName("TTIATag"); entity.Property(e => e.VendorId) .HasMaxLength(50) .HasDefaultValueSql("('Zerova')"); entity.HasOne(d => d.Customer).WithMany(p => p.Machines) .HasForeignKey(d => d.CustomerId) .HasConstraintName("FK_dbo.Machine_dbo.Customer_CustomerId"); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.ConfigureName, e.ChargeBoxId }).HasName("PK_dbo.MachineConfigurations"); entity.HasIndex(e => new { e.ConfigureName, e.ConfigureSetting }, "nci_wi_MachineConfigurations_132E765C043BF95A2570D2EA019DD783"); entity.Property(e => e.ConfigureName).HasMaxLength(50); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.ConfigureSetting).HasMaxLength(500); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.MachineError"); entity.ToTable("MachineError"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.ErrorInfo).HasMaxLength(50); entity.Property(e => e.VendorErrorCode).HasMaxLength(100); entity.Property(e => e.VendorId).HasMaxLength(255); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.MachineOperateRecord"); entity.ToTable("MachineOperateRecord"); entity.Property(e => e.Action).HasMaxLength(30); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.EvseStatus).HasColumnName("EVSE_Status"); entity.Property(e => e.EvseValue).HasColumnName("EVSE_Value"); entity.Property(e => e.FinishedOn).HasColumnType("datetime"); entity.Property(e => e.ReportedOn).HasColumnType("datetime"); entity.Property(e => e.SerialNo).HasMaxLength(36); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.MachineVersionFile"); entity.ToTable("MachineVersionFile"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.UploadFileId) .IsRequired() .HasMaxLength(36); entity.HasOne(d => d.UploadFile).WithMany(p => p.MachineVersionFiles) .HasForeignKey(d => d.UploadFileId) .HasConstraintName("FK_dbo.MachineVersionFile_dbo.UploadFile_UploadFileId"); }); modelBuilder.Entity(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); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.OCMF"); entity.ToTable("OCMF"); entity.Property(e => e.DataString).HasMaxLength(2048); entity.Property(e => e.PublicKey).HasMaxLength(256); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.ServerMessage"); entity.ToTable("ServerMessage"); entity.HasIndex(e => new { e.ReceivedOn, e.UpdatedOn, e.CreatedOn }, "nci_wi_ServerMessage_EC00C205420F6CB01974705B93F9507F"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedBy).HasMaxLength(36); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.OutAction).HasMaxLength(30); entity.Property(e => e.ReceivedOn).HasColumnType("datetime"); entity.Property(e => e.SerialNo).HasMaxLength(36); entity.Property(e => e.UpdatedOn).HasColumnType("datetime"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.TransactionRecord"); entity.ToTable("TransactionRecord"); entity.HasIndex(e => new { e.CustomerId, e.ConnectorId, e.StartTime, e.ChargeBoxId }, "IX_TransactionRecord_StartTime"); entity.HasIndex(e => new { e.CustomerId, e.StopTransactionReportedOn, e.StopTime }, "nci_wi_TransactionRecord_92D4DF08E7034102014AC91760F890FE"); entity.Property(e => e.ChargeBoxId) .IsRequired() .HasMaxLength(50); entity.Property(e => e.Cost).HasColumnType("decimal(18, 2)"); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.Evccid) .HasMaxLength(30) .HasColumnName("EVCCID"); entity.Property(e => e.Fee).HasMaxLength(1500); entity.Property(e => e.MeterStart).HasColumnType("decimal(18, 2)"); entity.Property(e => e.MeterStop).HasColumnType("decimal(18, 2)"); entity.Property(e => e.Receipt).HasMaxLength(3000); entity.Property(e => e.StartIdTag).HasMaxLength(20); entity.Property(e => e.StartSoc) .HasMaxLength(3) .HasColumnName("StartSOC"); entity.Property(e => e.StartTime).HasColumnType("datetime"); entity.Property(e => e.StartTransactionReportedOn).HasColumnType("datetime"); entity.Property(e => e.StopIdTag).HasMaxLength(20); entity.Property(e => e.StopReason).HasMaxLength(60); entity.Property(e => e.StopSoc) .HasMaxLength(3) .HasColumnName("StopSOC"); entity.Property(e => e.StopTime).HasColumnType("datetime"); entity.Property(e => e.StopTransactionReportedOn).HasColumnType("datetime"); entity.Property(e => e.UpdatedOn).HasColumnType("datetime"); entity.Property(e => e.UploadedtoTtia).HasColumnName("UploadedtoTTIA"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_dbo.UploadFile"); entity.ToTable("UploadFile"); entity.Property(e => e.Id).HasMaxLength(36); entity.Property(e => e.CreatedBy).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.FileExtensionName).HasMaxLength(50); entity.Property(e => e.FileMd5) .HasMaxLength(50) .HasColumnName("FileMD5"); entity.Property(e => e.FileName) .IsRequired() .HasMaxLength(500); entity.Property(e => e.FilePath) .IsRequired() .HasMaxLength(500); entity.Property(e => e.FileType).HasMaxLength(200); entity.Property(e => e.FileUrl).HasMaxLength(512); entity.Property(e => e.ModelName) .IsRequired() .HasMaxLength(50); entity.Property(e => e.OriginName) .IsRequired() .HasMaxLength(500); entity.Property(e => e.VendorId) .IsRequired() .HasMaxLength(50); }); modelBuilder.Entity(entity => { entity .HasNoKey() .ToView("vConnectorStatus"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.CreatedOn).HasColumnType("datetime"); entity.Property(e => e.ErrorInfo).HasMaxLength(50); entity.Property(e => e.Id) .IsRequired() .HasMaxLength(36); entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)"); entity.Property(e => e.VendorErrorCode).HasMaxLength(100); entity.Property(e => e.VendorId).HasMaxLength(255); }); modelBuilder.Entity(entity => { entity .HasNoKey() .ToView("vConnectorStatusCombind"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.Ocpp) .IsRequired() .HasMaxLength(3) .IsUnicode(false) .HasColumnName("OCPP"); entity.Property(e => e.TotalEnergy).HasColumnType("decimal(10, 2)"); entity.Property(e => e.VendorErrorCode).HasMaxLength(100); }); modelBuilder.Entity(entity => { entity .HasNoKey() .ToView("vMachine"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.ConnectorType).HasMaxLength(50); entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime"); entity.Property(e => e.Id) .IsRequired() .HasMaxLength(36); entity.Property(e => e.ModelName) .IsRequired() .HasMaxLength(50); entity.Property(e => e.OfflineOn).HasColumnType("datetime"); entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)"); entity.Property(e => e.Ttiatag).HasColumnName("TTIATag"); entity.Property(e => e.VendorId).HasMaxLength(50); }); modelBuilder.Entity(entity => { entity .HasNoKey() .ToView("vMachineCombind"); entity.Property(e => e.ChargeBoxId).HasMaxLength(50); entity.Property(e => e.ConnectorType).HasMaxLength(50); entity.Property(e => e.HeartbeatUpdatedOn).HasColumnType("datetime"); entity.Property(e => e.Id) .IsRequired() .HasMaxLength(36); entity.Property(e => e.ModelName) .IsRequired() .HasMaxLength(50); entity.Property(e => e.Ocpp) .IsRequired() .HasMaxLength(3) .IsUnicode(false) .HasColumnName("OCPP"); entity.Property(e => e.OfflineOn).HasColumnType("datetime"); entity.Property(e => e.RatedPower).HasColumnType("decimal(6, 2)"); entity.Property(e => e.Ttiatag).HasColumnName("TTIATag"); entity.Property(e => e.VendorId).HasMaxLength(50); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }