Files
EonaCat.Logger/EonaCat.Logger.LogServer/Data/LogCentralDbContext.cs
2026-01-08 15:18:34 +01:00

33 lines
996 B
C#

using Microsoft.EntityFrameworkCore;
using LogCentral.Server.Models;
namespace LogCentral.Server.Data;
public class LogCentralDbContext : DbContext
{
public LogCentralDbContext(DbContextOptions<LogCentralDbContext> options)
: base(options) { }
public DbSet<LogEntry> LogEntries { get; set; }
public DbSet<Application> Applications { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<LogEntry>(entity =>
{
entity.HasKey(e => e.Id);
entity.HasIndex(e => e.Timestamp);
entity.HasIndex(e => e.ApplicationName);
entity.HasIndex(e => e.Level);
entity.HasIndex(e => e.Environment);
entity.Property(e => e.PropertiesJson).HasColumnType("TEXT");
});
modelBuilder.Entity<Application>(entity =>
{
entity.HasKey(e => e.Id);
entity.HasIndex(e => e.Name).IsUnique();
});
}
}