60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Sports.Entities;
|
|
|
|
namespace Sports.DbContexts
|
|
{
|
|
public partial class SportsContext : DbContext
|
|
{
|
|
public SportsContext()
|
|
{
|
|
}
|
|
|
|
public SportsContext(DbContextOptions<SportsContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
public virtual DbSet<Sport> Sports { 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=sports;Username=postgres;Password=postgres");
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Sport>(entity =>
|
|
{
|
|
entity.HasNoKey();
|
|
|
|
entity.ToTable("sport");
|
|
|
|
entity.Property(e => e.Abbreviation).HasColumnName("abbreviation");
|
|
|
|
entity.Property(e => e.ActiveStatus).HasColumnName("activeStatus");
|
|
|
|
entity.Property(e => e.Code).HasColumnName("code");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
|
|
entity.Property(e => e.Link).HasColumnName("link");
|
|
|
|
entity.Property(e => e.Name).HasColumnName("name");
|
|
|
|
entity.Property(e => e.SortOrder).HasColumnName("sortOrder");
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|
|
}
|