Files
telegram-bot/modules/Reputation/Data/ReputationContext.cs
T

20 lines
622 B
C#
Raw Normal View History

using Kruzya.TelegramBot.Core.EF;
using Microsoft.EntityFrameworkCore;
namespace West.TelegramBot.Reputation.Data;
public class ReputationContext : AutoSaveDbContext
{
public DbSet<UserReputation> UserReputation { get; set; } = null!;
public ReputationContext(DbContextOptions<ReputationContext> options) : base(options)
{
Database.EnsureCreated();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<UserReputation>().HasKey(e => new {e.ChatId, e.UserId});
modelBuilder.Entity<UserReputation>().HasIndex(e => e.ChatId);
}
}