2019-11-29 12:26:53 +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
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2019-11-29 13:47:05 +00:00
|
|
|
|
modelBuilder.AddAcl();
|
|
|
|
|
|
2019-12-02 12:22:40 +00:00
|
|
|
|
modelBuilder.Entity<DbButton>()
|
2019-11-29 12:26:53 +00:00
|
|
|
|
.HasKey(c => new { c.TariffId, c.PartnerId });
|
2019-12-02 09:12:16 +00:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<DbQuotaRow>()
|
|
|
|
|
.HasKey(c => new { c.Tenant, c.Path });
|
2019-11-29 12:26:53 +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
|
|
|
|
}
|