12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace AvaloniaApplication4.Models;
- public partial class PostgresContext : DbContext
- {
- public PostgresContext()
- {
- }
- public PostgresContext(DbContextOptions<PostgresContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Product> Products { 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=123qwe12qw");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.HasPostgresExtension("pg_catalog", "adminpack");
- modelBuilder.Entity<Product>(entity =>
- {
- entity
- .HasNoKey()
- .ToTable("product");
- entity.Property(e => e.Color)
- .HasMaxLength(20)
- .HasColumnName("color");
- entity.Property(e => e.Count).HasColumnName("count");
- entity.Property(e => e.Country)
- .HasMaxLength(40)
- .HasColumnName("country");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Price)
- .HasColumnType("money")
- .HasColumnName("price");
- entity.Property(e => e.Аutomobile).HasMaxLength(40);
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|