auto.bus_api/Server/Data/ApplicationDbContext.cs
cuqmbr a75ea56f69 nonatomic commit. check description for the list of changes
feat: add UserManagementService

feat: add CopmanyDriver relation and DriverManagementService

chore: pupulate database seeding class

fix: add review filtering by CompanyId
2023-05-02 14:57:46 +03:00

39 lines
1.6 KiB
C#

using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Server.Models;
using Route = Server.Models.Route;
namespace Server.Data;
public class ApplicationDbContext : IdentityDbContext<User>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
Database.EnsureCreated();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().Ignore(u => u.UserName).Ignore(u => u.NormalizedUserName);
modelBuilder.Entity<CompanyDriver>().HasKey(cd => new { cd.CompanyId, cd.DriverId });
}
public DbSet<Company> Companies { get; set; } = null!;
public DbSet<CompanyDriver> CompanyDrivers { get; set; } = null!;
public DbSet<Vehicle> Vehicles { get; set; } = null!;
public DbSet<VehicleEnrollment> VehicleEnrollments { get; set; } = null!;
public DbSet<Route> Routes { get; set; } = null!;
public DbSet<RouteAddress> RouteAddresses { get; set; } = null!;
public DbSet<Address> Addresses { get; set; } = null!;
public DbSet<RouteAddressDetails> RouteAddressDetails { get; set; } = null!;
public DbSet<City> Cities { get; set; } = null!;
public DbSet<State> States { get; set; } = null!;
public DbSet<Country> Countries { get; set; } = null!;
public DbSet<TicketGroup> TicketGroups { get; set; } = null!;
public DbSet<Ticket> Tickets { get; set; } = null!;
public DbSet<Review> Reviews { get; set; } = null!;
}