using System; using System.Collections.Generic; using CH.Dal.DbEntity; using Microsoft.EntityFrameworkCore; namespace CH.Dal; public partial class CHDbScaffoldedContext : DbContext { public CHDbScaffoldedContext() { } public CHDbScaffoldedContext(DbContextOptions options) : base(options) { } public virtual DbSet EnergyProviders { get; set; } public virtual DbSet EnergyRates { get; set; } public virtual DbSet EnergyRateExceptions { get; set; } public virtual DbSet EnergyRateUpdates { get; set; } public virtual DbSet Locations { get; set; } public virtual DbSet Machines { get; set; } public virtual DbSet Users { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseNpgsql("Name=Database:ConnectionString"); protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder .HasPostgresEnum("currency", new[] { "USD", "CAD" }) .HasPostgresEnum("energy_rate_exception_threshold_reset_type", new[] { "daily" }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("energy_provider_pkey"); entity.ToTable("energy_provider"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Active).HasColumnName("active"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.DisabledAt).HasColumnName("disabled_at"); entity.Property(e => e.Name) .HasMaxLength(255) .HasColumnName("name"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("energy_rate_pkey"); entity.ToTable("energy_rate"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Active).HasColumnName("active"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.DisabledAt).HasColumnName("disabled_at"); entity.Property(e => e.Name) .HasMaxLength(255) .HasColumnName("name"); entity.Property(e => e.Price).HasColumnName("price"); entity.Property(e => e.ProviderId).HasColumnName("provider_id"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); entity.HasOne(d => d.Provider).WithMany(p => p.EnergyRates) .HasForeignKey(d => d.ProviderId) .HasConstraintName("energy_rate_provider_id_fkey"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("energy_rate_exception_pkey"); entity.ToTable("energy_rate_exception"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.EndedAt).HasColumnName("ended_at"); entity.Property(e => e.EnergyThreshold).HasColumnName("energy_threshold"); entity.Property(e => e.Name) .HasMaxLength(255) .HasColumnName("name"); entity.Property(e => e.RateId).HasColumnName("rate_id"); entity.Property(e => e.StartedAt).HasColumnName("started_at"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); entity.HasOne(d => d.Rate).WithMany(p => p.EnergyRateExceptions) .HasForeignKey(d => d.RateId) .HasConstraintName("energy_rate_exception_rate_id_fkey"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("energy_rate_update_pkey"); entity.ToTable("energy_rate_update"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.AppliedAt).HasColumnName("applied_at"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.Rate).HasColumnName("rate"); entity.Property(e => e.RateId).HasColumnName("rate_id"); entity.Property(e => e.SendAlert) .HasDefaultValue(false) .HasColumnName("send_alert"); entity.Property(e => e.StartedAt).HasColumnName("started_at"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); entity.HasOne(d => d.RateNavigation).WithMany(p => p.EnergyRateUpdates) .HasForeignKey(d => d.RateId) .HasConstraintName("energy_rate_update_rate_id_fkey"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("location_pkey"); entity.ToTable("location"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.Name) .HasMaxLength(255) .HasColumnName("name"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("machine_pkey"); entity.ToTable("machine"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Address) .HasMaxLength(255) .HasColumnName("address"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.LocationId).HasColumnName("location_id"); entity.Property(e => e.Name) .HasMaxLength(255) .HasColumnName("name"); entity.Property(e => e.Status).HasColumnName("status"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); entity.Property(e => e.UserId).HasColumnName("user_id"); entity.HasOne(d => d.Location).WithMany(p => p.Machines) .HasForeignKey(d => d.LocationId) .HasConstraintName("machine_location_id_fkey"); entity.HasOne(d => d.User).WithMany(p => p.Machines) .HasForeignKey(d => d.UserId) .HasConstraintName("machine_user_id_fkey"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("users_pkey"); entity.ToTable("users"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.CreatedAt) .HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)") .HasColumnName("created_at"); entity.Property(e => e.Email) .HasMaxLength(255) .HasColumnName("email"); entity.Property(e => e.FirstName) .HasMaxLength(255) .HasColumnName("first_name"); entity.Property(e => e.LastName) .HasMaxLength(255) .HasColumnName("last_name"); entity.Property(e => e.SubjectId) .HasMaxLength(255) .HasColumnName("subject_id"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); entity.Property(e => e.Verified).HasColumnName("verified"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }