/
WorkshopManagementDBContext.cs
32 lines (25 loc) · 1.11 KB
/
WorkshopManagementDBContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Microsoft.EntityFrameworkCore;
using Pitstop.WorkshopManagementEventHandler.Model;
namespace Pitstop.WorkshopManagementEventHandler.DataAccess
{
public class WorkshopManagementDBContext : DbContext
{
public WorkshopManagementDBContext()
{ }
public WorkshopManagementDBContext(DbContextOptions<WorkshopManagementDBContext> options) : base(options)
{ }
public DbSet<Vehicle> Vehicles { get; set; }
public DbSet<Customer> Customers { get; set; }
public DbSet<MaintenanceJob> MaintenanceJobs { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<Vehicle>().HasKey(entity => entity.LicenseNumber);
builder.Entity<Vehicle>().ToTable("Vehicle");
builder.Entity<Customer>().HasKey(entity => entity.CustomerId);
builder.Entity<Customer>().ToTable("Customer");
builder.Entity<MaintenanceJob>().HasKey(entity => entity.Id);
builder.Entity<MaintenanceJob>().ToTable("MaintenanceJob");
base.OnModelCreating(builder);
}
}
}