32 lines
878 B
C#
32 lines
878 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TransportGuideDatabaseImplements.Models;
|
|
|
|
namespace TransportGuideDatabaseImplements
|
|
{
|
|
public class TransportGuideDB : DbContext
|
|
{
|
|
string dbName = ConfigurationManager.AppSettings["connectToDb"];
|
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (optionsBuilder.IsConfigured == false)
|
|
{
|
|
optionsBuilder.UseNpgsql(dbName);
|
|
}
|
|
base.OnConfiguring(optionsBuilder);
|
|
}
|
|
public virtual DbSet<Route> Routes { set; get; }
|
|
public virtual DbSet<Stop> Stops { set; get; }
|
|
public virtual DbSet<StopRoute> StopRoutes { set; get; }
|
|
public virtual DbSet<TransportType> TransportTypes { set; get; }
|
|
}
|
|
}
|