using BlueWest.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace BlueWest.WebApi.MySQL;
///
/// Countries and Currencies
///
public class CountryDbContext : DbContext
{
public DbSet Countries { get; set; }
public DbSet Currencies { get; set; }
public DbSet Users { get; set; }
public IConfiguration Configuration;
///
/// Options to be injected in the app
///
///
public CountryDbContext(DbContextOptions options) : base(options)
{
Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
/*optionsBuilder.UseMySql(
Configuration.GetConnectionString("LocalMySQL"),
new MySqlServerVersion(new Version(8, 0, 11))
);*/
}
///
/// The country number is the primary key
/// The currency code is the primary key
///
///
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ProjectDatabaseModel();
}
}