2025-01-28 12:37:06 +00:00
using System ;
using System.Collections.Generic ;
using Microsoft.EntityFrameworkCore ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
namespace demo_2023.Models ;
public partial class User15Context : DbContext
{
public User15Context ( )
{
}
public User15Context ( DbContextOptions < User15Context > options )
: base ( options )
{
}
public virtual DbSet < Activity > Activities { get ; set ; }
public virtual DbSet < City > Cities { get ; set ; }
public virtual DbSet < Client > Clients { get ; set ; }
public virtual DbSet < Country > Countries { get ; set ; }
public virtual DbSet < Event > Events { get ; set ; }
public virtual DbSet < Eventactivity > Eventactivities { get ; set ; }
public virtual DbSet < Jhuriactivity > Jhuriactivities { get ; set ; }
public virtual DbSet < JuryEvent > JuryEvents { get ; set ; }
public virtual DbSet < ModerEvent > ModerEvents { get ; set ; }
public virtual DbSet < Role > Roles { get ; set ; }
public virtual DbSet < ValidActivityJhuri > ValidActivityJhuris { get ; set ; }
public virtual DbSet < ValidActivityModerator > ValidActivityModerators { get ; set ; }
public virtual DbSet < ValidActivityWinner > ValidActivityWinners { 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=45.67.56.214;Username=user15;Port=5421;Database=user15;Password=3XkvwMOb" ) ;
protected override void OnModelCreating ( ModelBuilder modelBuilder )
{
modelBuilder . Entity < Activity > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "activity_pkey" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . ToTable ( "activity" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Name )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "name" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . HasMany ( d = > d . Moderators ) . WithMany ( p = > p . Activities )
. UsingEntity < Dictionary < string , object > > (
"Activitymoderator" ,
2025-01-28 18:00:31 +00:00
r = > r . HasOne < Client > ( ) . WithMany ( )
. HasForeignKey ( "Moderatorid" )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_moderator" ) ,
2025-01-28 18:00:31 +00:00
l = > l . HasOne < Activity > ( ) . WithMany ( )
. HasForeignKey ( "Activityid" )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_activity" ) ,
j = >
{
j . HasKey ( "Activityid" , "Moderatorid" ) . HasName ( "activitymoderator_pkey" ) ;
j . ToTable ( "activitymoderator" ) ;
j . IndexerProperty < int > ( "Activityid" ) . HasColumnName ( "activityid" ) ;
j . IndexerProperty < int > ( "Moderatorid" ) . HasColumnName ( "moderatorid" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . HasMany ( d = > d . Winners ) . WithMany ( p = > p . ActivitiesNavigation )
. UsingEntity < Dictionary < string , object > > (
"Activitywinner" ,
2025-01-28 18:00:31 +00:00
r = > r . HasOne < Client > ( ) . WithMany ( )
. HasForeignKey ( "Winnerid" )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_moderator" ) ,
2025-01-28 18:00:31 +00:00
l = > l . HasOne < Activity > ( ) . WithMany ( )
. HasForeignKey ( "Activityid" )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_activity" ) ,
j = >
{
j . HasKey ( "Activityid" , "Winnerid" ) . HasName ( "activitywinner_pkey" ) ;
j . ToTable ( "activitywinner" ) ;
j . IndexerProperty < int > ( "Activityid" ) . HasColumnName ( "activityid" ) ;
j . IndexerProperty < int > ( "Winnerid" ) . HasColumnName ( "winnerid" ) ;
} ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < City > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "city_pkey" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . ToTable ( "city" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Name )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "name" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < Client > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "clients_pkey" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . ToTable ( "clients" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
entity . Property ( e = > e . Country ) . HasColumnName ( "country" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Date )
. HasColumnType ( "timestamp(6) without time zone" )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "date" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Email )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "email" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Fio )
. HasMaxLength ( 200 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "fio" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Gender )
. HasMaxLength ( 1 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "gender" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Password )
. HasMaxLength ( 50 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "password" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Phone )
. HasMaxLength ( 20 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "phone" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Photopath )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "photopath" ) ;
entity . Property ( e = > e . Role ) . HasColumnName ( "role" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Spec )
. HasMaxLength ( 50 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "spec" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . CountryNavigation ) . WithMany ( p = > p . Clients )
. HasForeignKey ( d = > d . Country )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_country" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . RoleNavigation ) . WithMany ( p = > p . Clients )
. HasForeignKey ( d = > d . Role )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_role" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < Country > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "country_pkey" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . ToTable ( "country" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . HasIndex ( e = > e . Code2 , "country_code2_key" ) . IsUnique ( ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Code )
. HasMaxLength ( 5 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "code" ) ;
entity . Property ( e = > e . Code2 ) . HasColumnName ( "code2" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . EnName )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "en_name" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Name )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "name" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < Event > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "event_pkey" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . ToTable ( "event" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . HasIndex ( e = > e . Date , "event_date_key" ) . IsUnique ( ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
entity . Property ( e = > e . City ) . HasColumnName ( "city" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Date )
. HasColumnType ( "timestamp(6) without time zone" )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "date" ) ;
entity . Property ( e = > e . Days ) . HasColumnName ( "days" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Photo )
. HasMaxLength ( 100 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "photo" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Sobitie )
. HasMaxLength ( 200 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "sobitie" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . CityNavigation ) . WithMany ( p = > p . Events )
. HasForeignKey ( d = > d . City )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_city" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < Eventactivity > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToTable ( "eventactivity" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Activityid ) . HasColumnName ( "activityid" ) ;
entity . Property ( e = > e . Eventid ) . HasColumnName ( "eventid" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . Activity ) . WithMany ( )
. HasForeignKey ( d = > d . Activityid )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_activity" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . Event ) . WithMany ( )
. HasForeignKey ( d = > d . Eventid )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_event" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < Jhuriactivity > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToTable ( "jhuriactivity" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Activityid ) . HasColumnName ( "activityid" ) ;
entity . Property ( e = > e . Jhuriid ) . HasColumnName ( "jhuriid" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . Activity ) . WithMany ( )
. HasForeignKey ( d = > d . Activityid )
. OnDelete ( DeleteBehavior . ClientSetNull )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_activity" ) ;
2025-01-28 18:00:31 +00:00
entity . HasOne ( d = > d . Jhuri ) . WithMany ( )
. HasForeignKey ( d = > d . Jhuriid )
2025-01-28 12:37:06 +00:00
. HasConstraintName ( "fk_moderator" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < JuryEvent > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToTable ( "jury_event" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . EventId ) . HasColumnName ( "event_id" ) ;
entity . Property ( e = > e . JuryId ) . HasColumnName ( "jury_id" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < ModerEvent > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToTable ( "moder_event" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . EventId ) . HasColumnName ( "event_id" ) ;
entity . Property ( e = > e . ModerId ) . HasColumnName ( "moder_id" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < Role > ( entity = >
{
entity . HasKey ( e = > e . Id ) . HasName ( "roles_pkey" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . ToTable ( "roles" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Id ) . HasColumnName ( "id" ) ;
2025-01-28 18:00:31 +00:00
entity . Property ( e = > e . Name )
. HasMaxLength ( 20 )
2025-01-28 12:37:06 +00:00
. HasColumnName ( "name" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < ValidActivityJhuri > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToView ( "valid_activity_jhuri" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Activityid ) . HasColumnName ( "activityid" ) ;
entity . Property ( e = > e . Jhuriid ) . HasColumnName ( "jhuriid" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < ValidActivityModerator > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToView ( "valid_activity_moderators" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Activityid ) . HasColumnName ( "activityid" ) ;
entity . Property ( e = > e . Moderatorid ) . HasColumnName ( "moderatorid" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
modelBuilder . Entity < ValidActivityWinner > ( entity = >
{
2025-01-28 18:00:31 +00:00
entity
. HasNoKey ( )
2025-01-28 12:37:06 +00:00
. ToView ( "valid_activity_winners" ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
entity . Property ( e = > e . Activityid ) . HasColumnName ( "activityid" ) ;
entity . Property ( e = > e . Winnerid ) . HasColumnName ( "winnerid" ) ;
} ) ;
2025-01-28 18:00:31 +00:00
2025-01-28 12:37:06 +00:00
OnModelCreatingPartial ( modelBuilder ) ;
}
partial void OnModelCreatingPartial ( ModelBuilder modelBuilder ) ;
}