Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Luticate2DbContext.cs 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using Luticate2.Auth.Auth.DataAccess.Models;
  2. using Microsoft.EntityFrameworkCore;
  3. namespace Luticate2.Auth.Auth.DataAccess
  4. {
  5. public class Luticate2DbContext : DbContext
  6. {
  7. public virtual DbSet<LuGroups> LuGroups { get; set; }
  8. public virtual DbSet<LuGroupsObjects> LuGroupsObjects { get; set; }
  9. public virtual DbSet<LuObjectsMetadata> LuObjectsMetadata { get; set; }
  10. public virtual DbSet<LuUsers> LuUsers { get; set; }
  11. public Luticate2DbContext()
  12. {
  13. }
  14. public Luticate2DbContext(DbContextOptions options) : base(options)
  15. {
  16. }
  17. protected override void OnModelCreating(ModelBuilder modelBuilder)
  18. {
  19. modelBuilder.HasPostgresExtension("citext")
  20. .HasPostgresExtension("unaccent")
  21. .HasPostgresExtension("uuid-ossp");
  22. modelBuilder.Entity<LuGroups>(entity =>
  23. {
  24. entity.ToTable("lu_groups", "luticate2");
  25. entity.HasIndex(e => e.Name)
  26. .HasName("lu_groups_name_key")
  27. .IsUnique();
  28. entity.Property(e => e.Id)
  29. .HasColumnName("id")
  30. .HasDefaultValueSql("luticate2.lu_sp_generate_uuid('lu_groups'::text)");
  31. entity.Property(e => e.Name)
  32. .IsRequired()
  33. .HasColumnName("name")
  34. .HasColumnType("citext");
  35. entity.HasOne(d => d.IdNavigation)
  36. .WithOne(p => p.LuGroups)
  37. .HasForeignKey<LuGroups>(d => d.Id)
  38. .OnDelete(DeleteBehavior.ClientSetNull)
  39. .HasConstraintName("lu_groups_id_fkey");
  40. });
  41. modelBuilder.Entity<LuGroupsObjects>(entity =>
  42. {
  43. entity.HasKey(e => new { e.GroupId, e.ObjectId });
  44. entity.ToTable("lu_groups_objects", "luticate2");
  45. entity.HasIndex(e => new { e.ObjectId, e.Priority })
  46. .HasName("lu_groups_objects_object_id_priority_key")
  47. .IsUnique();
  48. entity.Property(e => e.GroupId).HasColumnName("group_id");
  49. entity.Property(e => e.ObjectId).HasColumnName("object_id");
  50. entity.Property(e => e.Priority).HasColumnName("priority");
  51. entity.HasOne(d => d.Group)
  52. .WithMany(p => p.LuGroupsObjects)
  53. .HasForeignKey(d => d.GroupId)
  54. .HasConstraintName("lu_groups_objects_group_id_fkey");
  55. entity.HasOne(d => d.Object)
  56. .WithMany(p => p.LuGroupsObjects)
  57. .HasForeignKey(d => d.ObjectId)
  58. .OnDelete(DeleteBehavior.ClientSetNull)
  59. .HasConstraintName("lu_groups_objects_object_id_fkey");
  60. });
  61. modelBuilder.Entity<LuObjectsMetadata>(entity =>
  62. {
  63. entity.ToTable("lu_objects_metadata", "luticate2");
  64. entity.Property(e => e.Id)
  65. .HasColumnName("id")
  66. .HasDefaultValueSql("luticate2.lu_sp_generate_uuid('lu_objects_metadata'::text)");
  67. entity.Property(e => e.CreatedAt)
  68. .HasColumnName("created_at")
  69. .HasColumnType("timestamp with time zone")
  70. .HasDefaultValueSql("now()");
  71. entity.Property(e => e.UpdatedAt)
  72. .HasColumnName("updated_at")
  73. .HasColumnType("timestamp with time zone");
  74. });
  75. modelBuilder.Entity<LuUsers>(entity =>
  76. {
  77. entity.ToTable("lu_users", "luticate2");
  78. entity.HasIndex(e => e.Username)
  79. .HasName("lu_users_username_key")
  80. .IsUnique();
  81. entity.Property(e => e.Id)
  82. .HasColumnName("id")
  83. .HasDefaultValueSql("luticate2.lu_sp_generate_uuid('lu_users'::text)");
  84. entity.Property(e => e.Username)
  85. .IsRequired()
  86. .HasColumnName("username")
  87. .HasColumnType("citext");
  88. entity.HasOne(d => d.IdNavigation)
  89. .WithOne(p => p.LuUsers)
  90. .HasForeignKey<LuUsers>(d => d.Id)
  91. .OnDelete(DeleteBehavior.ClientSetNull)
  92. .HasConstraintName("lu_users_id_fkey");
  93. });
  94. }
  95. }
  96. }