CatBaseContext.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaApplicationBase.Models;
  5. public partial class CatBaseContext : DbContext
  6. {
  7. public CatBaseContext()
  8. {
  9. }
  10. public CatBaseContext(DbContextOptions<CatBaseContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<CatTable> CatTables { get; set; }
  15. public virtual DbSet<GenderTable> GenderTables { get; set; }
  16. public virtual DbSet<TraitCatTable> TraitCatTables { get; set; }
  17. public virtual DbSet<TraitTable> TraitTables { get; set; }
  18. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  19. #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
  20. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=CatBase;Username=43P;Password=444444");
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. modelBuilder.Entity<CatTable>(entity =>
  24. {
  25. entity.HasKey(e => e.Id).HasName("cat_table_pk");
  26. entity.ToTable("cat_table");
  27. entity.Property(e => e.Id).HasColumnName("id");
  28. entity.Property(e => e.Date)
  29. .HasColumnType("timestamp without time zone")
  30. .HasColumnName("date");
  31. entity.Property(e => e.Gender).HasColumnName("gender");
  32. entity.Property(e => e.Name)
  33. .HasColumnType("character varying")
  34. .HasColumnName("name");
  35. entity.HasOne(d => d.GenderNavigation).WithMany(p => p.CatTables)
  36. .HasForeignKey(d => d.Gender)
  37. .OnDelete(DeleteBehavior.ClientSetNull)
  38. .HasConstraintName("cat_table_fk");
  39. });
  40. modelBuilder.Entity<GenderTable>(entity =>
  41. {
  42. entity.HasKey(e => e.Id).HasName("gender_table_pk");
  43. entity.ToTable("gender_table");
  44. entity.Property(e => e.Id).HasColumnName("id");
  45. entity.Property(e => e.Gender)
  46. .HasColumnType("character varying")
  47. .HasColumnName("gender");
  48. });
  49. modelBuilder.Entity<TraitCatTable>(entity =>
  50. {
  51. entity.HasKey(e => e.Id).HasName("trait_cat_table_pk");
  52. entity.ToTable("trait_cat_table");
  53. entity.Property(e => e.Id).HasColumnName("id");
  54. entity.Property(e => e.IdCat).HasColumnName("id_cat");
  55. entity.Property(e => e.IdTrait).HasColumnName("id_trait");
  56. entity.HasOne(d => d.IdCatNavigation).WithMany(p => p.TraitCatTables)
  57. .HasForeignKey(d => d.IdCat)
  58. .OnDelete(DeleteBehavior.ClientSetNull)
  59. .HasConstraintName("trait_cat_table_fk");
  60. entity.HasOne(d => d.IdTraitNavigation).WithMany(p => p.TraitCatTables)
  61. .HasForeignKey(d => d.IdTrait)
  62. .OnDelete(DeleteBehavior.ClientSetNull)
  63. .HasConstraintName("trait_cat_table_fk_1");
  64. });
  65. modelBuilder.Entity<TraitTable>(entity =>
  66. {
  67. entity.HasKey(e => e.Id).HasName("trait_table_pk");
  68. entity.ToTable("trait_table");
  69. entity.Property(e => e.Id).HasColumnName("id");
  70. entity.Property(e => e.Trait)
  71. .HasColumnType("character varying")
  72. .HasColumnName("trait");
  73. });
  74. OnModelCreatingPartial(modelBuilder);
  75. }
  76. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  77. }