Files
DiunaBI/WebAPI/AppDbContext.cs

33 lines
1.0 KiB
C#
Raw Normal View History

2023-02-22 12:12:38 +01:00
using Microsoft.EntityFrameworkCore;
using WebAPI.Models;
2024-06-18 19:40:16 +02:00
namespace WebAPI;
2024-08-25 16:45:36 +02:00
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
2023-02-22 12:12:38 +01:00
{
2024-06-18 19:40:16 +02:00
public DbSet<User> Users { get; init; }
public DbSet<Layer> Layers { get; init; }
public DbSet<Record> Records { get; init; }
public DbSet<ProcessSource> ProcessSources { get; init; }
2024-08-25 16:45:36 +02:00
public DbSet<DataInbox> DataInbox { get; init; }
public DbSet<QueueJob> QueueJobs { get; init; }
2023-02-22 12:12:38 +01:00
2024-06-18 19:40:16 +02:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ProcessSource>().HasKey(x => new
2023-02-22 12:12:38 +01:00
{
2024-06-18 19:40:16 +02:00
x.LayerId,
x.SourceId
});
}
2023-02-22 12:12:38 +01:00
2024-06-18 19:40:16 +02:00
private static readonly LoggerFactory MyLoggerFactory =
new(new[] {
new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider()
2023-02-22 12:12:38 +01:00
});
2024-06-18 19:40:16 +02:00
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLoggerFactory(MyLoggerFactory);
2023-02-22 12:12:38 +01:00
}
2024-06-18 19:40:16 +02:00
}