using ASC.Core.Common.EF; using ASC.Webhooks.Core.Dao.Models; using Microsoft.EntityFrameworkCore; using ASC.Core.Common.EF.Model; using System.Collections.Generic; using System; using ASC.Core.Common.EF.Context; using ASC.Common; #nullable disable namespace ASC.Webhooks.Core.Dao { public class MySqlWebhooksDbContext : WebhooksDbContext { } public class PostgreSqlWebhooksDbContext : WebhooksDbContext { } public partial class WebhooksDbContext : BaseDbContext { public virtual DbSet WebhooksConfigs { get; set; } public virtual DbSet WebhooksLogs { get; set; } public WebhooksDbContext() { } public WebhooksDbContext(DbContextOptions options) : base(options) { } protected override Dictionary> ProviderContext { get { return new Dictionary>() { { Provider.MySql, () => new MySqlWebhooksDbContext() } , { Provider.Postgre, () => new PostgreSqlWebhooksDbContext() } , }; } } protected override void OnModelCreating(ModelBuilder modelBuilder) { ModelBuilderWrapper .From(modelBuilder, Provider) .AddWebhooksConfig() .AddWebhooksLog(); } } public static class WebhooksDbExtension { public static DIHelper AddWebhooksDbContextService(this DIHelper services) { return services.AddDbContextManagerService(); } } }