50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Seasons.Entities;
|
|
|
|
namespace Seasons.DbContexts
|
|
{
|
|
public partial class SeasonsContext : DbContext
|
|
{
|
|
public SeasonsContext()
|
|
{
|
|
}
|
|
|
|
public SeasonsContext(DbContextOptions<SeasonsContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
public virtual DbSet<Season> Seasons { get; set; } = null!;
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (!optionsBuilder.IsConfigured)
|
|
{
|
|
#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=5440;Database=seasons;Username=postgres;Password=postgres");
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Season>(entity =>
|
|
{
|
|
entity.HasNoKey();
|
|
|
|
entity.ToTable("season");
|
|
|
|
entity.Property(e => e.Active).HasColumnName("active");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|
|
}
|