65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using BlueWest.Data;
|
|
using CodeLiturgy.Domain.Model;
|
|
using CodeLiturgy.Domain.Extensions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using BlueWest.EfMethods;
|
|
|
|
namespace CodeLiturgy.Domain
|
|
{
|
|
|
|
/// <summary>
|
|
/// Countries and Currencies
|
|
/// </summary>
|
|
[EfGenerator]
|
|
public sealed class CountryDbContext : DbContext
|
|
{
|
|
|
|
#region Countries
|
|
|
|
/// <summary>
|
|
/// Countries
|
|
/// </summary>
|
|
|
|
[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<Country> Countries { get; set; }
|
|
|
|
#endregion
|
|
|
|
|
|
#region Initialization
|
|
/// <summary>
|
|
/// App Configuration
|
|
/// </summary>
|
|
public IConfiguration Configuration;
|
|
|
|
|
|
/// <summary>
|
|
/// CountryDbContext Constructor.
|
|
/// </summary>
|
|
/// <param name="options"></param>
|
|
public CountryDbContext(DbContextOptions<CountryDbContext> options) : base(options)
|
|
{
|
|
Database.EnsureCreated();
|
|
}
|
|
|
|
/// <summary>
|
|
/// On model creating.
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
modelBuilder.ConfigureCurrentDbModel();
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|