Files
ECMJobRunner/ECMJobRunner.Infrastructure/Data/JobRunnerDbContext.cs
TekH ff6faa1e5b Add JobRunnerDbContext with multi-framework support
Introduce `JobRunnerDbContext` to support both EF6 (.NET 4.8)
and EF Core (.NET 8) using conditional compilation. Add `DbSet`
properties for `CfgProfiles`, `ProfileSqlJobs`, and
`ProfileHistories`. Provide constructors for both frameworks
to handle connection strings or options. Ensure compatibility
with multiple runtime environments.
2026-07-09 13:34:03 +02:00

54 lines
1.4 KiB
C#

#if NET48
using System.Data.Entity;
#else
using Microsoft.EntityFrameworkCore;
#endif
using ECMJobRunner.Domain.Entities;
namespace ECMJobRunner.Infrastructure.Data
{
/// <summary>
/// Entity Framework DbContext for ECM Job Runner
/// </summary>
public class JobRunnerDbContext : DbContext
{
/// <summary>
/// Profile entities
/// </summary>
public DbSet<CfgProfile> CfgProfiles { get; set; } = null!;
/// <summary>
/// ProfileSqlJob entities
/// </summary>
public DbSet<ProfileSqlJob> ProfileSqlJobs { get; set; } = null!;
/// <summary>
/// ProfileHistory entities
/// </summary>
public DbSet<ProfileHistory> ProfileHistories { get; set; } = null!;
#if NET48
/// <summary>
/// Default constructor for Entity Framework 6 (.NET Framework 4.8)
/// </summary>
public JobRunnerDbContext() : base("name=JobRunnerConnection")
{
}
/// <summary>
/// Constructor with connection string for Entity Framework 6
/// </summary>
public JobRunnerDbContext(string connectionString) : base(connectionString)
{
}
#else
/// <summary>
/// Constructor for Entity Framework Core (.NET 8)
/// </summary>
public JobRunnerDbContext(DbContextOptions<JobRunnerDbContext> options) : base(options)
{
}
#endif
}
}