43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
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 MySqlFilesDbContext : FilesDbContext { }
|
|
public class PostgreSqlFilesDbContext : FilesDbContext { }
|
|
public class FilesDbContext : BaseDbContext
|
|
{
|
|
public DbSet<FilesConverts> FilesConverts { get; set; }
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
|
{
|
|
get
|
|
{
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
{
|
|
{ Provider.MySql, () => new MySqlFilesDbContext() } ,
|
|
{ Provider.Postgre, () => new PostgreSqlFilesDbContext() } ,
|
|
};
|
|
}
|
|
}
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
ModelBuilderWrapper
|
|
.From(modelBuilder, Provider)
|
|
.AddFilesConverts();
|
|
}
|
|
}
|
|
|
|
public static class FilesDbExtension
|
|
{
|
|
public static DIHelper AddFilesDbContextService(this DIHelper services)
|
|
{
|
|
return services.AddDbContextManagerService<FilesDbContext>();
|
|
}
|
|
}
|
|
}
|