CodeLiturgy.Dashboard/BlueWest.Api/Context/CompanyDbContext.cs

76 lines
2.0 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>
/// Companies.
/// </summary>
[EfAddMethods(typeof(CompanyCreate), typeof(CompanyUnique))]
/*[EFUpdateMethods(typeof(int),
"Id",
typeof(CompanyUpdate),
typeof(CompanyUnique))]*/
public DbSet<Company> Companies { get; set; }
/// <summary>
/// Industries.
/// </summary>
[EfAddMethods(typeof(IndustryCreate), typeof(IndustryUnique))]
/*[EFUpdateMethods(typeof(int),
"Id",
typeof(IndustryUpdate),
typeof(IndustryUnique))]*/
public DbSet<Industry> Industries { get; set; }
void TestExtensions()
{
// var (result, obj) = this.AddCountry(new CountryCreate());
}
/// <summary>
/// Products.
/// </summary>
/*
[EfAddMethods(typeof(ProductCreate))]
[EFUpdateMethods(typeof(int),
"Id",
typeof(ProductUpdate))]
*/
public DbSet<Product> Products { get; set; }
/// <summary>
/// CompanyDbContext constructor.
/// </summary>
/// <param name="options"></param>
public CompanyDbContext(DbContextOptions<CompanyDbContext> options) : base(options)
{
Database.EnsureCreated();
}
/// <summary>
/// On model creating.
/// </summary>
/// <param name="modelBuilder">Builder model of the database</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureCurrentDbModel();
}
}
}