This commit is contained in:
2026-01-08 15:18:34 +01:00
parent d385119ca2
commit 33a0b77bf1
111 changed files with 85489 additions and 24 deletions

View File

@@ -0,0 +1,32 @@
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();
});
}
}