Updated
This commit is contained in:
32
EonaCat.Logger.LogServer/Data/LogCentralDbContext.cs
Normal file
32
EonaCat.Logger.LogServer/Data/LogCentralDbContext.cs
Normal 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user