2022-08-04 03:59:04 +03:00
|
|
|
using BlueWest.Data;
|
2022-08-22 00:14:50 +03:00
|
|
|
using BlueWest.WebApi.EF.Model;
|
2022-08-04 03:59:04 +03:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
2022-08-22 00:14:50 +03:00
|
|
|
namespace BlueWest.WebApi.EF
|
2022-08-04 03:59:04 +03:00
|
|
|
{
|
2022-08-13 06:35:36 +03:00
|
|
|
|
2022-08-22 02:51:45 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Database context for app users
|
|
|
|
/// </summary>
|
|
|
|
public sealed class UserDbContext : DbContext
|
2022-08-18 22:59:13 +03:00
|
|
|
{
|
2022-08-22 02:51:45 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Users entity.
|
|
|
|
/// </summary>
|
|
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// App configuration.
|
|
|
|
/// </summary>
|
|
|
|
public IConfiguration Configuration;
|
2022-08-18 22:59:13 +03:00
|
|
|
|
2022-08-19 02:02:57 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Database for the context of database users
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="options"></param>
|
2022-08-22 02:51:45 +03:00
|
|
|
public UserDbContext(DbContextOptions<UserDbContext> options) : base(options)
|
2022-08-18 22:59:13 +03:00
|
|
|
{
|
|
|
|
Database.EnsureCreated();
|
|
|
|
}
|
2022-08-04 03:59:04 +03:00
|
|
|
|
2022-08-22 02:51:45 +03:00
|
|
|
/// <summary>
|
|
|
|
/// On database model creating
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="modelBuilder">Builder model of the database</param>
|
2022-08-18 22:59:13 +03:00
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
2022-08-04 03:59:04 +03:00
|
|
|
{
|
2022-08-18 22:59:13 +03:00
|
|
|
base.OnModelCreating(modelBuilder);
|
2022-08-20 05:47:32 +03:00
|
|
|
modelBuilder.ConfigureCurrentDbModel();
|
2022-08-18 22:59:13 +03:00
|
|
|
}
|
2022-08-04 03:59:04 +03:00
|
|
|
}
|
2022-08-18 22:59:13 +03:00
|
|
|
}
|