DocSpace-buildtools/common/ASC.Core.Common/EF/Context/CoreDbContext.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2019-12-17 13:01:59 +00:00

using Microsoft.EntityFrameworkCore;
2019-11-29 13:47:05 +00:00
using Microsoft.Extensions.DependencyInjection;
2019-11-29 12:26:53 +00:00
namespace ASC.Core.Common.EF
{
public class CoreDbContext : BaseDbContext
{
2019-12-02 12:22:40 +00:00
public DbSet<DbTariff> Tariffs { get; set; }
public DbSet<DbButton> Buttons { get; set; }
2019-11-29 13:47:05 +00:00
public DbSet<Acl> Acl { get; set; }
2019-12-02 09:12:16 +00:00
public DbSet<DbQuota> Quotas { get; set; }
public DbSet<DbQuotaRow> QuotaRows { get; set; }
2019-11-29 12:26:53 +00:00
2019-12-17 08:27:38 +00:00
public CoreDbContext() { }
public CoreDbContext(DbContextOptions<CoreDbContext> options)
: base(options)
{
}
2019-11-29 12:26:53 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
2019-12-17 13:01:59 +00:00
modelBuilder
.AddAcl()
.AddDbButton()
.AddDbQuotaRow();
2019-11-29 12:26:53 +00:00
}
}
2019-11-29 13:47:05 +00:00
2019-12-17 13:01:59 +00:00
2019-11-29 13:47:05 +00:00
public static class CoreDbExtension
{
public static IServiceCollection AddCoreDbContextService(this IServiceCollection services)
{
2019-12-10 15:06:51 +00:00
return services.AddDbContextManagerService<CoreDbContext>();
2019-11-29 13:47:05 +00:00
}
}
2019-11-29 12:26:53 +00:00
}