ShmelevTeamContext.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace FinancialManagement.Models;
  5. public partial class ShmelevTeamContext : DbContext
  6. {
  7. public ShmelevTeamContext()
  8. {
  9. }
  10. public ShmelevTeamContext(DbContextOptions<ShmelevTeamContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Categoriesfinance> Categoriesfinances { get; set; }
  15. public virtual DbSet<Category> Categories { get; set; }
  16. public virtual DbSet<Finance> Finances { get; set; }
  17. public virtual DbSet<User> Users { 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=ngknn.ru;Port=5442;Database=shmelev_team;Username=31P;Password=12345");
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. modelBuilder.Entity<Categoriesfinance>(entity =>
  24. {
  25. entity.HasKey(e => e.IdCatFin).HasName("categoriesfinance_pkey");
  26. entity.ToTable("categoriesfinance");
  27. entity.Property(e => e.IdCatFin).HasColumnName("id_cat_fin");
  28. entity.Property(e => e.FinTitle).HasMaxLength(100);
  29. });
  30. modelBuilder.Entity<Category>(entity =>
  31. {
  32. entity.HasKey(e => e.CategoryId).HasName("category_pkey");
  33. entity.ToTable("category");
  34. entity.Property(e => e.CategoryId).HasColumnName("category_id");
  35. entity.Property(e => e.IdUser).HasColumnName("id_user");
  36. entity.Property(e => e.Title)
  37. .HasMaxLength(100)
  38. .HasColumnName("title");
  39. entity.HasOne(d => d.IdUserNavigation).WithMany(p => p.Categories)
  40. .HasForeignKey(d => d.IdUser)
  41. .OnDelete(DeleteBehavior.ClientSetNull)
  42. .HasConstraintName("category_id_user_fkey");
  43. });
  44. modelBuilder.Entity<Finance>(entity =>
  45. {
  46. entity.HasKey(e => e.FinanceId).HasName("finance_pkey");
  47. entity.ToTable("finance");
  48. entity.Property(e => e.FinanceId).HasColumnName("finance_id");
  49. entity.Property(e => e.CategoryFinId).HasColumnName("category_fin_id");
  50. entity.Property(e => e.CategoryId).HasColumnName("category_id");
  51. entity.Property(e => e.DataRecording)
  52. .HasDefaultValueSql("CURRENT_TIMESTAMP")
  53. .HasColumnType("timestamp without time zone")
  54. .HasColumnName("data_recording");
  55. entity.Property(e => e.Price).HasColumnName("price");
  56. entity.Property(e => e.Title)
  57. .HasMaxLength(100)
  58. .HasColumnName("title");
  59. entity.Property(e => e.UserId).HasColumnName("user_id");
  60. entity.HasOne(d => d.CategoryFin).WithMany(p => p.Finances)
  61. .HasForeignKey(d => d.CategoryFinId)
  62. .OnDelete(DeleteBehavior.ClientSetNull)
  63. .HasConstraintName("finance_category_fin_id_fkey");
  64. entity.HasOne(d => d.Category).WithMany(p => p.Finances)
  65. .HasForeignKey(d => d.CategoryId)
  66. .OnDelete(DeleteBehavior.ClientSetNull)
  67. .HasConstraintName("finance_category_id_fkey");
  68. entity.HasOne(d => d.User).WithMany(p => p.Finances)
  69. .HasForeignKey(d => d.UserId)
  70. .OnDelete(DeleteBehavior.ClientSetNull)
  71. .HasConstraintName("finance_user_id_fkey");
  72. });
  73. modelBuilder.Entity<User>(entity =>
  74. {
  75. entity.HasKey(e => e.UserId).HasName("users_pkey");
  76. entity.ToTable("users");
  77. entity.Property(e => e.UserId).HasColumnName("user_id");
  78. entity.Property(e => e.Login)
  79. .HasMaxLength(50)
  80. .HasColumnName("login");
  81. entity.Property(e => e.Password)
  82. .HasMaxLength(50)
  83. .HasColumnName("password");
  84. entity.Property(e => e.Phone)
  85. .HasMaxLength(12)
  86. .HasColumnName("phone");
  87. entity.Property(e => e.Username)
  88. .HasMaxLength(50)
  89. .HasColumnName("username");
  90. });
  91. OnModelCreatingPartial(modelBuilder);
  92. }
  93. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  94. }