DocSpace-buildtools/common/ASC.Core.Common/EF/Context/UserDbContext.cs

65 lines
1.9 KiB
C#
Raw Normal View History

2020-10-06 07:06:18 +00:00
using System;
using System.Collections.Generic;
2020-10-12 16:23:15 +00:00
2020-10-06 07:06:18 +00:00
using ASC.Common;
2020-09-02 15:23:39 +00:00
using ASC.Core.Common.EF.Model;
2020-10-12 16:23:15 +00:00
2020-02-17 08:58:14 +00:00
using Microsoft.EntityFrameworkCore;
2019-11-25 09:49:12 +00:00
namespace ASC.Core.Common.EF
{
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 17:52:13 +00:00
public class MySqlUserDbContext : UserDbContext { }
2020-10-06 07:06:18 +00:00
2021-10-12 10:23:20 +00:00
public class PostgreSqlUserDbContext : UserDbContext
2020-10-06 07:06:18 +00:00
{
}
public class UserDbContext : BaseDbContext
2019-11-25 09:49:12 +00:00
{
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; }
2019-12-02 12:04:22 +00:00
public DbSet<DbSubscriptionMethod> SubscriptionMethods { get; set; }
2019-11-25 09:49:12 +00:00
2020-10-06 07:06:18 +00:00
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
{
return new Dictionary<Provider, Func<BaseDbContext>>()
{
{ Provider.MySql, () => new MySqlUserDbContext() } ,
2021-10-12 10:23:20 +00:00
{ Provider.PostgreSql, () => new PostgreSqlUserDbContext() } ,
2020-10-06 07:06:18 +00:00
};
}
}
2019-12-17 08:27:38 +00:00
2019-11-25 11:49:21 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
2019-11-25 09:49:12 +00:00
{
2020-10-12 19:39:23 +00:00
ModelBuilderWrapper
2020-09-02 15:23:39 +00:00
.From(modelBuilder, Provider)
2020-09-06 22:49:03 +00:00
.AddSubscriptionMethod()
2020-09-02 15:23:39 +00:00
.AddUser()
2020-09-06 22:49:03 +00:00
.AddAcl()
.AddUserSecurity()
.AddUserPhoto()
.AddDbGroup()
.AddUserGroup()
2020-10-05 10:02:28 +00:00
.AddSubscription();
2019-11-25 09:49:12 +00:00
}
}
2019-12-02 12:04:22 +00:00
public static class UserDbExtension
{
2020-02-17 08:58:14 +00:00
public static DIHelper AddUserDbContextService(this DIHelper services)
2019-12-02 12:04:22 +00:00
{
2019-12-10 15:06:51 +00:00
return services.AddDbContextManagerService<UserDbContext>();
2019-12-02 12:04:22 +00:00
}
}
2019-11-25 09:49:12 +00:00
}