using BlueWest.Data; 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( createType: typeof(CountryCreate), returnType: typeof(CountryUnique)) ] [EfUpdateMethods( updateType: typeof(CountryUpdate), returnType: typeof(CountryUnique), keyPropertyMemberName: "Id", keyPropertyMemberType: typeof(int)) ] public DbSet Countries { get; set; } /// /// Currencies Database Table /// // Generate Add extension methods [EfAddMethods(typeof(CurrencyCreate), typeof(CurrencyUnique))] [EfUpdateMethods( updateType: typeof(CurrencyUpdate), returnType: typeof(CurrencyUnique), keyPropertyMemberName: "Id", keyPropertyMemberType: typeof(int)) ] 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(); } } }