using Microsoft.EntityFrameworkCore; using Luticate2.Auth.DataAccess.Models; using Test.Utils.DataAccess.Models; namespace Test.Utils.DataAccess { public partial class LuUtilsDbContext : DbContext { private readonly string _connectionString; public LuUtilsDbContext() { } public LuUtilsDbContext(string connectionString) { _connectionString = connectionString; } public LuUtilsDbContext(DbContextOptions options) :base(options) { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (_connectionString != null) { optionsBuilder.UseNpgsql(_connectionString); } } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .HasKey(c => new { c.id }); modelBuilder.Entity() .Property(e => e.id) .HasDefaultValueSql("nextval('pk_bigserial_id_seq'::regclass)"); modelBuilder.Entity() .Property(e => e.created_at) .HasDefaultValueSql("now()"); modelBuilder.Entity() .HasKey(c => new { c.id }); modelBuilder.Entity() .Property(e => e.id) .HasDefaultValueSql("get_uuid()"); modelBuilder.Entity() .Property(e => e.created_at) .HasDefaultValueSql("now()"); } public virtual DbSet pk_bigserial { get; set; } public virtual DbSet pk_guid { get; set; } } }