using Microsoft.EntityFrameworkCore; using Luticate2.Auth.DataAccess.Models; namespace Luticate2.Auth.DataAccess { public partial class LuAuthDatabaseContext : DbContext { private readonly string _connectionString; public LuAuthDatabaseContext() { } public LuAuthDatabaseContext(string connectionString) { _connectionString = connectionString; } public LuAuthDatabaseContext(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("get_uuid()"); modelBuilder.Entity() .HasKey(c => new { c.id }); modelBuilder.Entity() .Property(e => e.id) .HasDefaultValueSql("get_uuid()"); modelBuilder.Entity() .HasKey(c => new { c.id }); modelBuilder.Entity() .Property(e => e.id) .HasDefaultValueSql("get_uuid()"); modelBuilder.Entity() .HasOne(e => e.fk_lu_authentication_sources) .WithMany(e => e.lu_users_fk) .HasForeignKey("authentication_source_id") .HasConstraintName("lu_users_authentication_source_id_fkey"); modelBuilder.Entity() .HasKey(c => new { c.user_id, c.group_id }); modelBuilder.Entity() .HasOne(e => e.fk_lu_users) .WithMany(e => e.lu_verb_users_groups_fk) .HasForeignKey("user_id") .HasConstraintName("lu_verb_users_groups_user_id_fkey"); modelBuilder.Entity() .HasOne(e => e.fk_lu_groups) .WithMany(e => e.lu_verb_users_groups_fk) .HasForeignKey("group_id") .HasConstraintName("lu_verb_users_groups_group_id_fkey"); } public virtual DbSet lu_authentication_sources { get; set; } public virtual DbSet lu_groups { get; set; } public virtual DbSet lu_users { get; set; } public virtual DbSet lu_verb_users_groups { get; set; } } }