12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using Microsoft.EntityFrameworkCore;
- using Luticate2.Auth.DataAccess.Models;
-
- namespace Luticate2.Auth.DataAccess
- {
- public partial class LuDatabaseContext : DbContext
- {
- private readonly string _connectionString;
-
- public LuDatabaseContext()
- {
- }
-
- public LuDatabaseContext(string connectionString)
- {
- _connectionString = connectionString;
- }
-
- public LuDatabaseContext(DbContextOptions options) :base(options)
- {
- }
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- if (_connectionString != null) {
- optionsBuilder.UseNpgsql(_connectionString);
- }
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
-
- modelBuilder.Entity<lu_authentication_sources>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<lu_authentication_sources>()
- .Property(e => e.id)
- .HasDefaultValueSql("get_uuid()");
-
-
-
- modelBuilder.Entity<lu_groups>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<lu_groups>()
- .Property(e => e.id)
- .HasDefaultValueSql("get_uuid()");
-
-
-
- modelBuilder.Entity<lu_users>()
- .HasKey(c => new { c.id });
-
- modelBuilder.Entity<lu_users>()
- .Property(e => e.id)
- .HasDefaultValueSql("get_uuid()");
-
-
- modelBuilder.Entity<lu_users>()
- .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<lu_verb_users_groups>()
- .HasKey(c => new { c.user_id, c.group_id });
-
-
- modelBuilder.Entity<lu_verb_users_groups>()
- .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<lu_verb_users_groups>()
- .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> lu_authentication_sources { get; set; }
-
- public virtual DbSet<lu_groups> lu_groups { get; set; }
-
- public virtual DbSet<lu_users> lu_users { get; set; }
-
- public virtual DbSet<lu_verb_users_groups> lu_verb_users_groups { get; set; }
-
- }
- }
|