2022-02-15 11:52:43 +00:00
|
|
|
|
namespace ASC.Core.Common.EF.Context;
|
|
|
|
|
|
|
|
|
|
public class MySqlDbContext : DbContext { }
|
|
|
|
|
public class PostgreSqlDbContext : DbContext { }
|
|
|
|
|
public class DbContext : BaseDbContext
|
2019-12-12 15:24:47 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public DbSet<MobileAppInstall> MobileAppInstall { get; set; }
|
|
|
|
|
public DbSet<DbipLocation> DbipLocation { get; set; }
|
|
|
|
|
public DbSet<Regions> Regions { get; set; }
|
2019-12-17 08:27:38 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public DbContext() { }
|
2019-12-17 08:27:38 +00:00
|
|
|
|
|
2022-02-15 12:30:54 +00:00
|
|
|
|
public DbContext(DbContextOptions options) : base(options) { }
|
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
|
|
|
|
{
|
|
|
|
|
get
|
2020-10-06 11:38:15 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
2020-10-06 11:38:15 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
{ Provider.MySql, () => new MySqlDbContext() } ,
|
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlDbContext() } ,
|
|
|
|
|
};
|
2019-12-12 15:24:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-15 11:52:43 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
ModelBuilderWrapper
|
|
|
|
|
.From(modelBuilder, Provider)
|
|
|
|
|
.AddMobileAppInstall()
|
|
|
|
|
.AddDbipLocation()
|
|
|
|
|
.AddRegions();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-13 11:37:58 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public static class DbContextExtension
|
|
|
|
|
{
|
|
|
|
|
public static DIHelper AddDbContextService(this DIHelper services)
|
2019-12-13 11:37:58 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
return services.AddDbContextManagerService<DbContext>();
|
2019-12-13 11:37:58 +00:00
|
|
|
|
}
|
2019-12-12 15:24:47 +00:00
|
|
|
|
}
|