autobus-api_old/AutobusApi.Infrastructure/Data/ApplicationDbContext.cs

72 lines
2.3 KiB
C#

using System.Reflection;
using AutobusApi.Application.Common.Interfaces;
using AutobusApi.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace AutoubsApi.Infrastructure.Data;
public class ApplicationDbContext : DbContext, IApplicationDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
public DbSet<Country> Countries { get => Set<Country>(); }
public DbSet<Region> Regions { get => Set<Region>(); }
public DbSet<City> Cities { get => Set<City>(); }
public DbSet<Address> Addresses { get => Set<Address>(); }
public DbSet<RouteAddress> RouteAddresses { get => Set<RouteAddress>(); }
public DbSet<Route> Routes { get => Set<Route>(); }
public DbSet<RouteAddressDetails> RouteAddressDetails { get => Set<RouteAddressDetails>(); }
public DbSet<VehicleEnrollment> VehicleEnrollments { get => Set<VehicleEnrollment>(); }
public DbSet<Vehicle> Vehicles { get => Set<Vehicle>(); }
public DbSet<Bus> Buses { get => Set<Bus>(); }
public DbSet<Aircraft> Aircraft { get => Set<Aircraft>(); }
public DbSet<Train> Trains { get => Set<Train>(); }
public DbSet<TrainCarriage> TrainCarriages { get => Set<TrainCarriage>(); }
public DbSet<Carriage> Carriages { get => Set<Carriage>(); }
public DbSet<Company> Companies { get => Set<Company>(); }
public DbSet<Employee> Employees { get => Set<Employee>(); }
public DbSet<EmployeeDocument> EmployeeDocuments { get => Set<EmployeeDocument>(); }
public DbSet<VehicleEnrollmentEmployee> vehicleEnrollmentEmployees { get => Set<VehicleEnrollmentEmployee>(); }
public DbSet<User> ApplicationUsers { get => Set<User>(); }
public DbSet<TicketGroup> TicketGroups { get => Set<TicketGroup>(); }
public DbSet<Ticket> Tickets { get => Set<Ticket>(); }
public DbSet<TicketDocument> TicketDocuments { get => Set<TicketDocument>(); }
public DbSet<Review> Reviews { get => Set<Review>(); }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.HasPostgresExtension("postgis");
builder.HasDefaultSchema("domain");
builder.ApplyConfigurationsFromAssembly(
Assembly.GetExecutingAssembly(),
t => t.Namespace == "AutobusApi.Infrastructure.Data.Configurations"
);
}
}