2023-02-22 12:12:38 +01:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
using WebAPI.Models;
|
|
|
|
|
|
|
2024-06-18 19:40:16 +02:00
|
|
|
|
namespace WebAPI;
|
|
|
|
|
|
|
|
|
|
|
|
public class AppDbContext : DbContext
|
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-07-03 19:21:25 +02:00
|
|
|
|
// public DbSet<DataInbox> DataInbox { get; set; }
|
2023-02-22 12:12:38 +01:00
|
|
|
|
|
2024-06-18 19:40:16 +02:00
|
|
|
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
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
|
|
|
|
}
|