constellation-api/CH.Dal/CHDbScaffoldedContext.cs

90 lines
2.8 KiB
C#
Raw Normal View History

2025-01-02 17:53:38 -05:00
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.Name)
.HasMaxLength(255)
.HasColumnName("name");
});
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.LocationId).HasColumnName("location_id");
entity.Property(e => e.Name)
.HasMaxLength(255)
.HasColumnName("name");
entity.Property(e => e.Status).HasColumnName("status");
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("user_pkey");
entity.ToTable("user");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Email)
.HasMaxLength(255)
.HasColumnName("email");
entity.Property(e => e.FirstName).HasMaxLength(255);
entity.Property(e => e.LastName).HasMaxLength(255);
entity.Property(e => e.SubjectId)
.HasMaxLength(255)
.HasColumnName("subject_id");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}