46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using BlueWest.Data;
|
|
using BlueWest.WebApi.Context.Users;
|
|
using BlueWest.WebApi.EF.Model;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace BlueWest.WebApi.EF
|
|
{
|
|
|
|
/// <summary>
|
|
/// Database context for app users
|
|
/// </summary>
|
|
public sealed class UserDbContext : DbContext
|
|
{
|
|
/// <summary>
|
|
/// Users entity.
|
|
/// </summary>
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// App configuration.
|
|
/// </summary>
|
|
public IConfiguration Configuration;
|
|
|
|
/// <summary>
|
|
/// Database for the context of database users
|
|
/// </summary>
|
|
/// <param name="options"></param>
|
|
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options)
|
|
{
|
|
Database.EnsureCreated();
|
|
}
|
|
|
|
/// <summary>
|
|
/// On model creating.
|
|
/// </summary>
|
|
/// <param name="modelBuilder">Builder model of the database</param>
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
modelBuilder.ConfigureCurrentDbModel();
|
|
}
|
|
}
|
|
}
|