AppForKidsDesktop/AppForKids/models/KidsAppDbContext.cs
2024-12-26 10:39:55 +03:00

44 lines
1.6 KiB
C#

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.
=> optionsBuilder.UseNpgsql("Host=localhost;Password=123;Database=kids_app_db;Port=5432;Username=postgres");
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);
}