53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
|
|
using BlueWest.Data;
|
|
using BlueWest.WebApi.EF.Model;
|
|
using MapTo;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace BlueWest.WebApi.EF
|
|
{
|
|
/// <summary>
|
|
/// Context for accessing company data
|
|
/// </summary>
|
|
public sealed class CompanyDbContext : DbContext
|
|
{
|
|
/// <summary>
|
|
/// Db set of Companies
|
|
/// </summary>
|
|
public DbSet<Company> Companies { get; set; }
|
|
|
|
/// <summary>
|
|
/// Db set of Industries.
|
|
/// </summary>
|
|
public DbSet<Industry> Industries { get; set; }
|
|
|
|
/// <summary>
|
|
/// Db set of Products.
|
|
/// </summary>
|
|
public DbSet<Product> Products { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Options to be injected in the app
|
|
/// </summary>
|
|
/// <param name="options"></param>
|
|
public CompanyDbContext(DbContextOptions<CompanyDbContext> options) : base(options)
|
|
{
|
|
Database.EnsureCreated();
|
|
}
|
|
|
|
/// <summary>
|
|
/// On database model creating
|
|
/// </summary>
|
|
/// <param name="modelBuilder">Builder model of the database</param>
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
modelBuilder.ConfigureCurrentDbModel();
|
|
}
|
|
|
|
}
|
|
}
|
|
|