AppDbContext.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using AvaloniaPractic.Models;
  4. using Microsoft.EntityFrameworkCore;
  5. namespace AvaloniaApplication2.Models;
  6. public partial class AppDbContext : DbContext
  7. {
  8. public DbSet<User> Users { get; set; } = null!;
  9. public DbSet<Role> Roles { get; set; } = null!;
  10. public DbSet<Logined> Logineds { get; set; }
  11. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  12. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=3128;Database=pavlov41p;Username=31P;Password=12345");
  13. protected override void OnModelCreating(ModelBuilder modelBuilder)
  14. {
  15. modelBuilder.Entity<User>(entity =>
  16. {
  17. entity.HasKey(e => e.Id).HasName("users_pkey");
  18. entity.ToTable("users");
  19. entity.Property(e => e.Id).HasColumnName("id");
  20. entity.Property(e => e.Createdat)
  21. .HasDefaultValueSql("CURRENT_TIMESTAMP")
  22. .HasColumnType("timestamp without time zone")
  23. .HasColumnName("createdat");
  24. entity.Property(e => e.Email)
  25. .HasMaxLength(255)
  26. .HasColumnName("email");
  27. entity.Property(e => e.Username)
  28. .HasMaxLength(100)
  29. .HasColumnName("username");
  30. });
  31. OnModelCreatingPartial(modelBuilder);
  32. }
  33. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  34. }