107 lines
3.7 KiB
C#
107 lines
3.7 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<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.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);
|
|
}
|