DocSpace-buildtools/common/ASC.Core.Common/EF/Context/MessagesContext.cs
diana-vahomskaya af84cd6532 fix Context
2021-08-03 17:11:53 +03:00

46 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 MySqlMessagesContext : MessagesContext { }
public class PostgreSqlMessagesContext : MessagesContext { }
public class MessagesContext : BaseDbContext
{
public DbSet<LoginEvents> LoginEvents { get; set; }
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
{
get
{
return new Dictionary<Provider, Func<BaseDbContext>>()
{
{ Provider.MySql, () => new MySqlMessagesContext() } ,
{ Provider.Postgre, () => new PostgreSqlMessagesContext() } ,
};
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ModelBuilderWrapper
.From(modelBuilder, Provider)
.AddLoginEvents()
.AddDbFunction();
}
}
public static class MessagesContextExtension
{
public static DIHelper AddMessagesContextService(this DIHelper services)
{
return services.AddDbContextManagerService<MessagesContext>();
}
}
}