using BlueWest.Data; using CodeLiturgy.Domain.Model; using CodeLiturgy.Domain.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using BlueWest.EfMethods; namespace CodeLiturgy.Domain { /// /// Countries and Currencies /// [EfGenerator] public sealed class CountryDbContext : DbContext { #region Countries /// /// Countries /// [EfGetOneBy(nameof(Country.Id), typeof(CountryUnique))] [EfGetOne(typeof(CountryUnique))] [EfAddMethods(createType: typeof(CountryCreate), returnType: typeof(CountryUnique))] [EfUpdateMethods( updateType: typeof(CountryUpdate), returnType: typeof(CountryUnique), keyPropertyMemberName: nameof(Country.Id))] [EfGetMany(typeof(CountryUnique))] public DbSet Countries { get; set; } #endregion #region Initialization /// /// 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(); } #endregion } }