2022-01-26 10:43:08 +00:00
|
|
|
|
namespace ASC.Core.Common.EF.Context
|
2019-12-04 09:04:32 +00:00
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
public class MySqlWebstudioDbContext : WebstudioDbContext { }
|
|
|
|
|
public class PostgreSqlWebstudioDbContext : WebstudioDbContext { }
|
2020-10-05 09:27:15 +00:00
|
|
|
|
public class WebstudioDbContext : BaseDbContext
|
2019-12-04 09:04:32 +00:00
|
|
|
|
{
|
|
|
|
|
public DbSet<DbWebstudioSettings> WebstudioSettings { get; set; }
|
2019-12-06 16:01:12 +00:00
|
|
|
|
public DbSet<DbWebstudioUserVisit> WebstudioUserVisit { get; set; }
|
2020-01-24 13:07:51 +00:00
|
|
|
|
public DbSet<DbWebstudioIndex> WebstudioIndex { get; set; }
|
2020-10-06 11:38:15 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
|
|
|
{
|
|
|
|
|
{ Provider.MySql, () => new MySqlWebstudioDbContext() } ,
|
2021-10-12 10:23:20 +00:00
|
|
|
|
{ Provider.PostgreSql, () => new PostgreSqlWebstudioDbContext() } ,
|
2020-10-06 11:38:15 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-04 09:04:32 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
ModelBuilderWrapper
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.From(modelBuilder, Provider)
|
|
|
|
|
.AddWebstudioSettings()
|
|
|
|
|
.AddWebstudioUserVisit()
|
2020-10-05 10:02:28 +00:00
|
|
|
|
.AddDbWebstudioIndex();
|
2019-12-04 09:04:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class WebstudioDbExtension
|
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
|
public static DIHelper AddWebstudioDbContextService(this DIHelper services)
|
2019-12-04 09:04:32 +00:00
|
|
|
|
{
|
2019-12-10 15:06:51 +00:00
|
|
|
|
return services.AddDbContextManagerService<WebstudioDbContext>();
|
2019-12-04 09:04:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|