DocSpace-buildtools/common/ASC.Core.Common/EF/Context/UserDbContext.cs
pavelbannov b1134d239c Merge branch 'develop' into feature/auto-migrations
# Conflicts:
#	common/ASC.Core.Common/EF/Context/UserDbContext.cs
#	common/ASC.Core.Common/EF/Model/DbWebstudioUservisit.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/20210309093101_AccountLinkContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/20210309093101_AccountLinkContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/20210803210910_AccountLinkContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/20210803210910_AccountLinkContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/20211012145324_AccountLinkContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/20211012145324_AccountLinkContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/AccountLinkContextMySql/MySqlAccountLinkContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/CoreDbContextMySql/20211012145320_CoreDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/CoreDbContextMySql/20211012145320_CoreDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/CoreDbContextMySql/MySqlCoreDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/20210309093934_DbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/20210309093934_DbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/20210803211510_DbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/20210803211510_DbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/20211012145326_DbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/20211012145326_DbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/DbContextMySql/MySqlDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/20210309094059_FeedDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/20210309094059_FeedDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/20210803211718_FeedDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/20210803211718_FeedDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/20211012145328_FeedDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/20211012145328_FeedDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/FeedDbContextMySql/MySqlFeedDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/20210309094212_FilesDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/20210309094212_FilesDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/20210803211941_FilesDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/20210803211941_FilesDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/20211012145330_FilesDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/20211012145330_FilesDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/FilesDbContextMySql/MySqlFilesDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/20210309094321_MailDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/20210309094321_MailDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/20210803212237_MailDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/20210803212237_MailDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/20211012145332_MailDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/20211012145332_MailDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/MailDbContextMySql/MySqlMailDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/MessagesContextMySql/20210803212546_MessagesContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/MessagesContextMySql/20211012145334_MessagesContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/MessagesContextMySql/MySqlMessagesContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/20210309094710_NotifyDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/20210309094710_NotifyDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/20210803212728_NotifyDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/20210803212728_NotifyDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/20211012145336_NotifyDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/20211012145336_NotifyDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/NotifyDbContextMySql/MySqlNotifyDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/20210309094839_ResourceDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/20210309094839_ResourceDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/20210803212948_ResourceDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/20210803212948_ResourceDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/20211012145338_ResourceDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/20211012145338_ResourceDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/ResourceDbContextMySql/MySqlResourceDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/20210309095003_TelegramDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/20210309095003_TelegramDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/20210803213120_TelegramDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/20210803213120_TelegramDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/20211012145340_TelegramDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/20211012145340_TelegramDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/TelegramDbContextMySql/MySqlTelegramDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/20210309095116_TenantDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/20210309095116_TenantDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/20210803213311_TenantDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/20210803213311_TenantDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/20211012145342_TenantDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/20211012145342_TenantDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/TenantDbContextMySql/MySqlTenantDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/UserDbContextMySql/20210309095256_UserDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/UserDbContextMySql/20210803213502_UserDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/UserDbContextMySql/20211012145322_UserDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/UserDbContextMySql/MySqlUserDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/20210309095409_VoipDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/20210309095409_VoipDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/20210803213656_VoipDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/20210803213656_VoipDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/20211012145344_VoipDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/20211012145344_VoipDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/VoipDbContextMySql/MySqlVoipDbContextModelSnapshot.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/20210309100343_WebstudioDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/20210309100343_WebstudioDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/20210803213819_WebstudioDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/20210803213819_WebstudioDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/20211012145346_WebstudioDbContextMySql.Designer.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/20211012145346_WebstudioDbContextMySql.cs
#	common/ASC.Core.Common/Migrations/MySql/WebstudioDbContextMySql/MySqlWebstudioDbContextModelSnapshot.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/20210309125119_FilesDbContextMySql.Designer.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/20210309125119_FilesDbContextMySql.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/20210804103345_FilesDbContextMySql.Designer.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/20210804103345_FilesDbContextMySql.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/20211022170840_FilesDbContextMySql.Designer.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/20211022170840_FilesDbContextMySql.cs
#	products/ASC.Files/Core/Migrations/MySql/FilesDbContextMySql/MySqlFilesDbContextModelSnapshot.cs
2021-10-25 20:52:13 +03:00

65 lines
1.9 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
{
public class MySqlUserDbContext : UserDbContext { }
public class PostgreSqlUserDbContext : UserDbContext
{
}
public class UserDbContext : BaseDbContext
{
public DbSet<User> Users { get; set; }
public DbSet<UserSecurity> UserSecurity { get; set; }
public DbSet<UserPhoto> Photos { get; set; }
public DbSet<Acl> Acl { get; set; }
public DbSet<DbGroup> Groups { get; set; }
public DbSet<UserGroup> UserGroups { get; set; }
public DbSet<Subscription> Subscriptions { get; set; }
public DbSet<DbSubscriptionMethod> SubscriptionMethods { get; set; }
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
{
return new Dictionary<Provider, Func<BaseDbContext>>()
{
{ Provider.MySql, () => new MySqlUserDbContext() } ,
{ Provider.PostgreSql, () => new PostgreSqlUserDbContext() } ,
};
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddSubscriptionMethod()
.AddUser()
.AddAcl()
.AddUserSecurity()
.AddUserPhoto()
.AddDbGroup()
.AddUserGroup()
.AddSubscription();
}
}
public static class UserDbExtension
{
public static DIHelper AddUserDbContextService(this DIHelper services)
{
return services.AddDbContextManagerService<UserDbContext>();
}
}
}