2024-12-26 07:39:55 +00:00
using System ;
using System.Collections.Generic ;
using Microsoft.EntityFrameworkCore ;
namespace AppForKids.models ;
public partial class KidsAppDbContext : DbContext
{
public KidsAppDbContext ( )
{
}
public KidsAppDbContext ( DbContextOptions < KidsAppDbContext > options )
: base ( options )
{
}
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.
2024-12-26 11:50:23 +00:00
= > optionsBuilder . UseNpgsql ( "Host=192.168.1.183;Password=123;Database=kids_app_db;Port=5432;Username=postgres" ) ;
2024-12-26 07:39:55 +00:00
protected override void OnModelCreating ( ModelBuilder modelBuilder )
{
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 . Clicks ) . HasColumnName ( "clicks" ) ;
entity . Property ( e = > e . Name ) . HasColumnName ( "name" ) ;
entity . Property ( e = > e . Password ) . HasColumnName ( "password" ) ;
entity . Property ( e = > e . Url ) . HasColumnName ( "url" ) ;
} ) ;
OnModelCreatingPartial ( modelBuilder ) ;
}
partial void OnModelCreatingPartial ( ModelBuilder modelBuilder ) ;
}