constellation-api/CH.Dal/CHDbScaffoldedContext.cs

208 lines
8.1 KiB
C#

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<EnergyProvider> EnergyProviders { get; set; }
public virtual DbSet<EnergyRate> EnergyRates { get; set; }
public virtual DbSet<EnergyRateException> EnergyRateExceptions { get; set; }
public virtual DbSet<EnergyRateUpdate> EnergyRateUpdates { get; set; }
public virtual DbSet<Location> Locations { get; set; }
public virtual DbSet<Machine> Machines { get; set; }
public virtual DbSet<User> 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<EnergyProvider>(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<EnergyRate>(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<EnergyRateException>(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<EnergyRateUpdate>(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.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.Rate).HasColumnName("rate");
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.RateNavigation).WithMany(p => p.EnergyRateUpdates)
.HasForeignKey(d => d.RateId)
.HasConstraintName("energy_rate_update_rate_id_fkey");
});
modelBuilder.Entity<Location>(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<Machine>(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<User>(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);
}