From ff6faa1e5b4b86c874b3249b4624de4f0fd76274 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 9 Jul 2026 13:34:03 +0200 Subject: [PATCH] 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. --- .../Data/JobRunnerDbContext.cs | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 ECMJobRunner.Infrastructure/Data/JobRunnerDbContext.cs diff --git a/ECMJobRunner.Infrastructure/Data/JobRunnerDbContext.cs b/ECMJobRunner.Infrastructure/Data/JobRunnerDbContext.cs new file mode 100644 index 0000000..06cbc40 --- /dev/null +++ b/ECMJobRunner.Infrastructure/Data/JobRunnerDbContext.cs @@ -0,0 +1,53 @@ +#if NET48 +using System.Data.Entity; +#else +using Microsoft.EntityFrameworkCore; +#endif +using ECMJobRunner.Domain.Entities; + +namespace ECMJobRunner.Infrastructure.Data +{ + /// + /// Entity Framework DbContext for ECM Job Runner + /// + public class JobRunnerDbContext : DbContext + { + /// + /// Profile entities + /// + public DbSet CfgProfiles { get; set; } = null!; + + /// + /// ProfileSqlJob entities + /// + public DbSet ProfileSqlJobs { get; set; } = null!; + + /// + /// ProfileHistory entities + /// + public DbSet ProfileHistories { get; set; } = null!; + +#if NET48 + /// + /// Default constructor for Entity Framework 6 (.NET Framework 4.8) + /// + public JobRunnerDbContext() : base("name=JobRunnerConnection") + { + } + + /// + /// Constructor with connection string for Entity Framework 6 + /// + public JobRunnerDbContext(string connectionString) : base(connectionString) + { + } +#else + /// + /// Constructor for Entity Framework Core (.NET 8) + /// + public JobRunnerDbContext(DbContextOptions options) : base(options) + { + } +#endif + } +}