/
VFlov
/
NotificationService_1
Обзор
Документация
Войти
/
VFlov
/
NotificationService_1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/Shared/NotificationService.Shared/Data/NotificationDbContext.cs
53 строки
2 KB
VFlov
first_commit
27 ноя 2025, 11:43
27 ноя 2025, 11:43
819df67
Код
Авторство
О чём код?
using Microsoft.EntityFrameworkCore; using NotificationService.Shared.Models; namespace NotificationService.Shared.Data; /// <summary> /// Контекст базы данных для уведомлений /// </summary> public class NotificationDbContext : DbContext { public NotificationDbContext(DbContextOptions<NotificationDbContext> options) : base(options) { } public DbSet<NotificationRecord> Notifications { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity<NotificationRecord>(entity => { entity.ToTable("Notifications"); entity.HasKey(e => e.Id); entity.Property(e => e.Recipient) .IsRequired() .HasMaxLength(500); entity.Property(e => e.Subject) .HasMaxLength(500); entity.Property(e => e.Content) .IsRequired(); entity.Property(e => e.Type) .IsRequired() .HasConversion<string>(); entity.Property(e => e.Status) .IsRequired() .HasConversion<string>(); entity.Property(e => e.ErrorMessage) .HasMaxLength(2000); entity.HasIndex(e => e.Status); entity.HasIndex(e => e.Type); entity.HasIndex(e => e.CreatedAt); }); } }