2025-02-04 13:58:34 +00:00
using System ;
using System.Collections.Generic ;
using Microsoft.EntityFrameworkCore ;
namespace dmeo040225.Models ;
public partial class DatabaseContext : DbContext
{
public DatabaseContext ( )
{
}
public DatabaseContext ( DbContextOptions < DatabaseContext > options )
: base ( options )
{
}
public virtual DbSet < Order > Orders { get ; set ; }
public virtual DbSet < OrdersService > OrdersServices { get ; set ; }
public virtual DbSet < Role > Roles { get ; set ; }
public virtual DbSet < Service > Services { get ; set ; }
public virtual DbSet < User > Users { 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 https://go.microsoft.com/fwlink/?LinkId=723263.
= > optionsBuilder . UseNpgsql ( "Host=localhost;Database=postgres;Username=postgres;Password=5432" ) ;
protected override void OnModelCreating ( ModelBuilder modelBuilder )
{
modelBuilder . Entity < Order > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "orders_pkey" ) ;
entity . ToTable ( "orders" ) ;
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
entity . Property ( e = > e . Code )
. HasMaxLength ( 255 )
. HasColumnName ( "code" ) ;
entity . Property ( e = > e . Orderdata )
. HasColumnType ( "timestamp without time zone" )
. HasColumnName ( "orderdata" ) ;
entity . Property ( e = > e . Ordertime ) . HasColumnName ( "ordertime" ) ;
entity . Property ( e = > e . Orederclosetime )
. HasColumnType ( "timestamp without time zone" )
. HasColumnName ( "orederclosetime" ) ;
entity . Property ( e = > e . Prokattime ) . HasColumnName ( "prokattime" ) ;
entity . Property ( e = > e . Status )
. HasMaxLength ( 255 )
. HasColumnName ( "status" ) ;
entity . Property ( e = > e . UserId ) . HasColumnName ( "user_id" ) ;
entity . HasOne ( d = > d . User ) . WithMany ( p = > p . Orders )
. HasForeignKey ( d = > d . UserId )
. HasConstraintName ( "orders_user_id_fkey" ) ;
} ) ;
modelBuilder . Entity < OrdersService > ( entity = >
{
2025-03-04 12:41:58 +00:00
entity . HasKey ( e = > e . Id ) . HasName ( "orders_services_pk" ) ;
2025-02-04 13:58:34 +00:00
2025-03-04 12:41:58 +00:00
entity . ToTable ( "orders_services" ) ;
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
2025-02-04 13:58:34 +00:00
entity . Property ( e = > e . OrderId ) . HasColumnName ( "order_id" ) ;
entity . Property ( e = > e . ServiceId ) . HasColumnName ( "service_id" ) ;
2025-03-04 12:41:58 +00:00
entity . HasOne ( d = > d . Order ) . WithMany ( p = > p . OrdersServices )
2025-02-04 13:58:34 +00:00
. HasForeignKey ( d = > d . OrderId )
. HasConstraintName ( "orders_services_order_id_fkey" ) ;
2025-03-04 12:41:58 +00:00
entity . HasOne ( d = > d . Service ) . WithMany ( p = > p . OrdersServices )
2025-02-04 13:58:34 +00:00
. HasForeignKey ( d = > d . ServiceId )
. HasConstraintName ( "orders_services_service_id_fkey" ) ;
} ) ;
modelBuilder . Entity < Role > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "role_pkey" ) ;
entity . ToTable ( "role" ) ;
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
entity . Property ( e = > e . Name )
. HasMaxLength ( 255 )
. HasColumnName ( "name" ) ;
} ) ;
modelBuilder . Entity < Service > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "services_pkey" ) ;
entity . ToTable ( "services" ) ;
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
entity . Property ( e = > e . Code )
. HasMaxLength ( 255 )
. HasColumnName ( "code" ) ;
entity . Property ( e = > e . Cost )
. HasMaxLength ( 255 )
. HasColumnName ( "cost" ) ;
entity . Property ( e = > e . Name )
. HasMaxLength ( 255 )
. HasColumnName ( "name" ) ;
} ) ;
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 . Adress )
. HasMaxLength ( 255 )
. HasColumnName ( "adress" ) ;
entity . Property ( e = > e . Birthday )
. HasColumnType ( "timestamp without time zone" )
. HasColumnName ( "birthday" ) ;
entity . Property ( e = > e . Codeclient )
. HasMaxLength ( 255 )
. HasColumnName ( "codeclient" ) ;
entity . Property ( e = > e . Fio )
. HasMaxLength ( 255 )
. HasColumnName ( "fio" ) ;
entity . Property ( e = > e . Lastlogin )
. HasColumnType ( "timestamp without time zone" )
. HasColumnName ( "lastlogin" ) ;
entity . Property ( e = > e . Login )
. HasMaxLength ( 255 )
. HasColumnName ( "login" ) ;
entity . Property ( e = > e . Logorno ) . HasColumnName ( "logorno" ) ;
entity . Property ( e = > e . Passport )
. HasMaxLength ( 255 )
. HasColumnName ( "passport" ) ;
entity . Property ( e = > e . Password )
. HasMaxLength ( 255 )
. HasColumnName ( "password" ) ;
entity . Property ( e = > e . Photopath )
. HasMaxLength ( 255 )
. HasColumnName ( "photopath" ) ;
entity . Property ( e = > e . RoleId ) . HasColumnName ( "role_id" ) ;
entity . HasOne ( d = > d . Role ) . WithMany ( p = > p . Users )
. HasForeignKey ( d = > d . RoleId )
. HasConstraintName ( "users_role_id_fkey" ) ;
} ) ;
OnModelCreatingPartial ( modelBuilder ) ;
}
partial void OnModelCreatingPartial ( ModelBuilder modelBuilder ) ;
}