You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuAuthDatabaseContext.cs 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Microsoft.EntityFrameworkCore;
  2. using Luticate2.Auth.DataAccess.Models;
  3. namespace Luticate2.Auth.DataAccess
  4. {
  5. public partial class LuAuthDatabaseContext : DbContext
  6. {
  7. private readonly string _connectionString;
  8. public LuAuthDatabaseContext()
  9. {
  10. }
  11. public LuAuthDatabaseContext(string connectionString)
  12. {
  13. _connectionString = connectionString;
  14. }
  15. public LuAuthDatabaseContext(DbContextOptions options) :base(options)
  16. {
  17. }
  18. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  19. {
  20. if (_connectionString != null) {
  21. optionsBuilder.UseNpgsql(_connectionString);
  22. }
  23. }
  24. protected override void OnModelCreating(ModelBuilder modelBuilder)
  25. {
  26. modelBuilder.Entity<lu_authentication_sources>()
  27. .HasKey(c => new { c.id });
  28. modelBuilder.Entity<lu_authentication_sources>()
  29. .Property(e => e.id)
  30. .HasDefaultValueSql("get_uuid()");
  31. modelBuilder.Entity<lu_groups>()
  32. .HasKey(c => new { c.id });
  33. modelBuilder.Entity<lu_groups>()
  34. .Property(e => e.id)
  35. .HasDefaultValueSql("get_uuid()");
  36. modelBuilder.Entity<lu_tokens>()
  37. .HasKey(c => new { c.id });
  38. modelBuilder.Entity<lu_tokens>()
  39. .HasOne(e => e.fk_lu_users)
  40. .WithMany(e => e.lu_tokens_fk)
  41. .HasForeignKey("user_id")
  42. .HasConstraintName("lu_tokens_user_id_fkey");
  43. modelBuilder.Entity<lu_users>()
  44. .HasKey(c => new { c.id });
  45. modelBuilder.Entity<lu_users>()
  46. .Property(e => e.id)
  47. .HasDefaultValueSql("get_uuid()");
  48. modelBuilder.Entity<lu_users>()
  49. .HasOne(e => e.fk_lu_authentication_sources)
  50. .WithMany(e => e.lu_users_fk)
  51. .HasForeignKey("authentication_source_id")
  52. .HasConstraintName("lu_users_authentication_source_id_fkey");
  53. modelBuilder.Entity<lu_verb_users_groups>()
  54. .HasKey(c => new { c.user_id, c.group_id });
  55. modelBuilder.Entity<lu_verb_users_groups>()
  56. .HasOne(e => e.fk_lu_users)
  57. .WithMany(e => e.lu_verb_users_groups_fk)
  58. .HasForeignKey("user_id")
  59. .HasConstraintName("lu_verb_users_groups_user_id_fkey");
  60. modelBuilder.Entity<lu_verb_users_groups>()
  61. .HasOne(e => e.fk_lu_groups)
  62. .WithMany(e => e.lu_verb_users_groups_fk)
  63. .HasForeignKey("group_id")
  64. .HasConstraintName("lu_verb_users_groups_group_id_fkey");
  65. }
  66. public virtual DbSet<lu_authentication_sources> lu_authentication_sources { get; set; }
  67. public virtual DbSet<lu_groups> lu_groups { get; set; }
  68. public virtual DbSet<lu_tokens> lu_tokens { get; set; }
  69. public virtual DbSet<lu_users> lu_users { get; set; }
  70. public virtual DbSet<lu_verb_users_groups> lu_verb_users_groups { get; set; }
  71. }
  72. }