Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sing System;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata;
- #nullable disable
- namespace Task_1
- {
- public partial class wg_forge_dbContext : DbContext
- {
- public wg_forge_dbContext()
- {
- }
- public wg_forge_dbContext(DbContextOptions<wg_forge_dbContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Cat> Cats { get; set; }
- public virtual DbSet<CatColorsInfo> CatColorsInfos { get; set; }
- public virtual DbSet<CatsStat> CatsStats { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- if (!optionsBuilder.IsConfigured)
- {
- optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=wg_forge_db;Username=wg_forge;Password=42a");
- }
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.HasPostgresEnum(null, "cat_color", new[] { "black", "white", "black & white", "red", "red & white", "red & black & white" })
- .HasAnnotation("Relational:Collation", "en_US.utf8");
- modelBuilder.Entity<Cat>(entity =>
- {
- entity.HasKey(e => e.Name)
- .HasName("cats_pkey");
- entity.ToTable("cats");
- entity.Property(e => e.Name)
- .HasColumnType("character varying")
- .HasColumnName("name");
- entity.Property(e => e.TailLength).HasColumnName("tail_length");
- entity.Property(e => e.WhiskersLength).HasColumnName("whiskers_length");
- });
- modelBuilder.Entity<CatColorsInfo>(entity =>
- {
- entity.HasNoKey();
- entity.ToTable("cat_colors_info");
- entity.Property(e => e.Count).HasColumnName("count");
- });
- modelBuilder.Entity<CatsStat>(entity =>
- {
- entity.HasNoKey();
- entity.ToTable("cats_stat");
- entity.Property(e => e.TailLengthMean).HasColumnName("tail_length_mean");
- entity.Property(e => e.TailLengthMedian).HasColumnName("tail_length_median");
- entity.Property(e => e.TailLengthMode).HasColumnName("tail_length_mode");
- entity.Property(e => e.WhiskersLengthMean).HasColumnName("whiskers_length_mean");
- entity.Property(e => e.WhiskersLengthMedian).HasColumnName("whiskers_length_median");
- entity.Property(e => e.WhiskersLengthMode).HasColumnName("whiskers_length_mode");
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement