2022-08-13 06:35:36 +03:00
|
|
|
using BlueWest.Data;
|
2022-08-22 00:14:50 +03:00
|
|
|
using BlueWest.WebApi.EF.Model;
|
2022-08-13 06:35:36 +03:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
2022-08-22 00:14:50 +03:00
|
|
|
namespace BlueWest.WebApi.EF
|
2022-08-13 06:35:36 +03:00
|
|
|
{
|
2022-08-20 05:47:32 +03:00
|
|
|
|
2022-08-13 20:15:43 +03:00
|
|
|
/// <summary>
|
2022-08-20 05:47:32 +03:00
|
|
|
/// Countries and Currencies
|
2022-08-13 20:15:43 +03:00
|
|
|
/// </summary>
|
2022-08-22 00:14:50 +03:00
|
|
|
internal sealed class CountryDbContext : DbContext
|
2022-08-13 06:35:36 +03:00
|
|
|
{
|
|
|
|
|
2022-08-20 05:47:32 +03:00
|
|
|
public DbSet<Country> Countries { get; set; }
|
|
|
|
|
|
|
|
public DbSet<Currency> Currencies { get; set; }
|
|
|
|
|
|
|
|
public IConfiguration Configuration;
|
2022-08-13 06:35:36 +03:00
|
|
|
|
2022-08-20 05:47:32 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Options to be injected in the app
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="options"></param>
|
|
|
|
public CountryDbContext(DbContextOptions<CountryDbContext> options) : base(options)
|
|
|
|
{
|
|
|
|
Database.EnsureCreated();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The country number is the primary key
|
|
|
|
/// The currency code is the primary key
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="modelBuilder"></param>
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
{
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.ConfigureCurrentDbModel();
|
|
|
|
}
|
2022-08-22 00:14:50 +03:00
|
|
|
|
2022-08-20 05:47:32 +03:00
|
|
|
}
|
|
|
|
}
|