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.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_users>()
  37. .HasKey(c => new { c.id });
  38. modelBuilder.Entity<lu_users>()
  39. .Property(e => e.id)
  40. .HasDefaultValueSql("get_uuid()");
  41. modelBuilder.Entity<lu_users>()
  42. .HasOne(e => e.fk_lu_authentication_sources)
  43. .WithMany(e => e.lu_users_fk)
  44. .HasForeignKey("authentication_source_id")
  45. .HasConstraintName("lu_users_authentication_source_id_fkey");
  46. modelBuilder.Entity<lu_verb_users_groups>()
  47. .HasKey(c => new { c.user_id, c.group_id });
  48. modelBuilder.Entity<lu_verb_users_groups>()
  49. .HasOne(e => e.fk_lu_users)
  50. .WithMany(e => e.lu_verb_users_groups_fk)
  51. .HasForeignKey("user_id")
  52. .HasConstraintName("lu_verb_users_groups_user_id_fkey");
  53. modelBuilder.Entity<lu_verb_users_groups>()
  54. .HasOne(e => e.fk_lu_groups)
  55. .WithMany(e => e.lu_verb_users_groups_fk)
  56. .HasForeignKey("group_id")
  57. .HasConstraintName("lu_verb_users_groups_group_id_fkey");
  58. }
  59. public virtual DbSet<lu_authentication_sources> lu_authentication_sources { get; set; }
  60. public virtual DbSet<lu_groups> lu_groups { get; set; }
  61. public virtual DbSet<lu_users> lu_users { get; set; }
  62. public virtual DbSet<lu_verb_users_groups> lu_verb_users_groups { get; set; }
  63. }
  64. }