using BlueWest.Data; using BlueWest.WebApi.Context; using BlueWest.WebApi.EF.Model; using MapTo; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; namespace BlueWest.WebApi.EF { /// /// Countries and Currencies /// public sealed class CountryDbContext : DbContext { /// /// Countries Database Table /// [EfAddMethods( createDto: typeof(CountryCreate), returnType: typeof(CountryUnique)) ] [EfAddUpdateMethods( updateType: typeof(CountryUpdate), returnType: typeof(CountryUnique), keyPropertyName: "Id", keyPropertyType: typeof(System.Int64)) ] public DbSet Countries { get; set; } /// /// Currencies Database Table /// // Generate Add extension methods [EfAddMethods(typeof(CurrencyCreate), typeof(CurrencyUnique))] [EfAddUpdateMethods( updateType: typeof(CurrencyUpdate), returnType: typeof(CurrencyUnique), keyPropertyName: "Id", keyPropertyType: typeof(System.Int64)) ] public DbSet Currencies { get; set; } //////////////////////////////////////////////// //////////////////////////////////////////////// /// /// App Configuration /// public IConfiguration Configuration; /// /// CountryDbContext Constructor. /// /// public CountryDbContext(DbContextOptions options) : base(options) { Database.EnsureCreated(); } /// /// On model creating. /// /// protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.ConfigureCurrentDbModel(); } } }