using System; using System.Collections.Generic; using ASC.Common; using ASC.Core.Common.EF.Model; using Microsoft.EntityFrameworkCore; namespace ASC.Core.Common.EF.Context { public class MySqlNotifyDbContext : NotifyDbContext { } public class PostgreSqlNotifyDbContext : NotifyDbContext { } public class NotifyDbContext : BaseDbContext { public DbSet NotifyInfo { get; set; } public DbSet NotifyQueue { get; set; } protected override Dictionary> ProviderContext { get { return new Dictionary>() { { Provider.MySql, () => new MySqlNotifyDbContext() } , { Provider.Postgre, () => new PostgreSqlNotifyDbContext() } , }; } } protected override void OnModelCreating(ModelBuilder modelBuilder) { ModelBuilderWrapper .From(modelBuilder, Provider) .AddNotifyInfo() .AddNotifyQueue(); } } public static class NotifyDbExtension { public static DIHelper AddNotifyDbContext(this DIHelper services) { return services.AddDbContextManagerService(); } } }