123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace exam.Models;
- public partial class PostgresContext : DbContext
- {
- public PostgresContext()
- {
- }
- public PostgresContext(DbContextOptions<PostgresContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Country> Countries { get; set; }
- public virtual DbSet<User> Users { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- #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.
- => optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=plo030803a");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.HasPostgresExtension("pg_catalog", "adminpack");
- modelBuilder.Entity<Country>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("countries_pkey");
- entity.ToTable("countries");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Country1)
- .HasMaxLength(100)
- .HasColumnName("country");
- });
- modelBuilder.Entity<User>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("users_pkey");
- entity.ToTable("users");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Firstname)
- .HasMaxLength(100)
- .HasColumnName("firstname");
- entity.Property(e => e.Idcountry).HasColumnName("idcountry");
- entity.Property(e => e.Lastname)
- .HasMaxLength(100)
- .HasColumnName("lastname");
- entity.Property(e => e.Loginuser)
- .HasMaxLength(100)
- .HasColumnName("loginuser");
- entity.Property(e => e.Passworsuser)
- .HasMaxLength(100)
- .HasColumnName("passworsuser");
- entity.HasOne(d => d.IdcountryNavigation).WithMany(p => p.Users)
- .HasForeignKey(d => d.Idcountry)
- .HasConstraintName("users_idcountry_fkey");
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|