CodeLiturgy.Dashboard/CodeLiturgy.Views/DbContexts/SiteDbContext.cs

37 lines
966 B
C#
Raw Permalink Normal View History

2022-11-18 01:39:36 +03:00
using CodeLiturgy.Data.Application;
using Microsoft.EntityFrameworkCore;
using BlueWest.EfMethods;
2022-11-18 03:38:56 +03:00
using CodeLiturgy.Domain.Model;
namespace CodeLiturgy.Domain
{
[EfGenerator]
public class SiteDbContext: DbContext
{
[EfGetOneBy(nameof(Site.Id), typeof(SiteUnique))]
[EfGetOne(typeof(SiteUnique))]
[EfGetMany(typeof(SiteUnique))]
public DbSet<Site> Sites { get; set; }
2022-11-18 03:15:53 +03:00
public DbSet<SiteEnvironment> Environments { get; set; }
/// <summary>
/// SiteDbContext Constructor.
/// </summary>
/// <param name="options"></param>
public SiteDbContext(DbContextOptions<SiteDbContext> options) : base(options)
{
Database.EnsureCreated();
}
2022-11-18 03:38:56 +03:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureCurrentDbModel();
}
}
}