using BlueWest.Data;
using BlueWest.WebApi.Context;
using BlueWest.WebApi.EF.Model;
using MapTo;
using Microsoft.EntityFrameworkCore;
namespace BlueWest.WebApi.EF
{
///
/// Context for accessing company data
///
public sealed class CompanyDbContext : DbContext
{
///
/// Companies.
///
[EfAddMethods(typeof(CompanyCreate), typeof(CompanyUnique))]
[EfAddUpdateMethods(
typeof(CompanyUnique),
typeof(CompanyUpdate),
"Id", typeof(int))
]
/*[EFUpdateMethods(typeof(int),
"Id",
typeof(CompanyUpdate),
typeof(CompanyUnique))]*/
public DbSet Companies { get; set; }
///
/// Industries.
///
[EfAddMethods(typeof(IndustryCreate), typeof(IndustryUnique))]
/*[EFUpdateMethods(typeof(int),
"Id",
typeof(IndustryUpdate),
typeof(IndustryUnique))]*/
public DbSet Industries { get; set; }
void TestExtensions()
{
// var (result, obj) = this.AddCountry(new CountryCreate());
}
///
/// Products.
///
/*
[EfAddMethods(typeof(ProductCreate))]
[EFUpdateMethods(typeof(int),
"Id",
typeof(ProductUpdate))]
*/
public DbSet Products { get; set; }
///
/// CompanyDbContext constructor.
///
///
public CompanyDbContext(DbContextOptions options) : base(options)
{
Database.EnsureCreated();
}
///
/// On model creating.
///
/// Builder model of the database
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureCurrentDbModel();
}
}
}