From 674c14dd7c7c9cab36f42848033732735af8a803 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 10 Dec 2025 12:02:20 +0100 Subject: [PATCH] Refactor Profile mapping to use Fluent API in DbContext Moved table and column mapping for Profile from data annotations in the entity class to Fluent API configuration in RecDbContext. Removes dependency on DataAnnotations in Profile.cs and centralizes entity configuration in the DbContext. --- src/ReC.Domain/Entities/Profile.cs | 20 +------------------- src/ReC.Infrastructure/RecDbContext.cs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/ReC.Domain/Entities/Profile.cs b/src/ReC.Domain/Entities/Profile.cs index 8f45ae6..5da1287 100644 --- a/src/ReC.Domain/Entities/Profile.cs +++ b/src/ReC.Domain/Entities/Profile.cs @@ -1,46 +1,28 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; +namespace ReC.Domain.Entities; -namespace ReC.Domain.Entities; - -[Table("TBREC_CFG_PROFILE", Schema = "dbo")] public class Profile { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Column("GUID")] public long Id { get; set; } - [Column("ACTIVE")] public bool? Active { get; set; } - [Column("TYPE")] public string? Type { get; set; } - [Column("MANDANTOR")] public string? Mandantor { get; set; } - [Column("PROFILE_NAME")] public string? Name { get; set; } - [Column("DESCRIPTION")] public string? Description { get; set; } - [Column("LOG_LEVEL")] public string? LogLevel { get; set; } - [Column("LANGUAGE")] public string? Language { get; set; } - [Column("ADDED_WHO")] public string? AddedWho { get; set; } - [Column("ADDED_WHEN")] public DateTime? AddedWhen { get; set; } - [Column("CHANGED_WHO")] public string? ChangedWho { get; set; } - [Column("CHANGED_WHEN")] public DateTime? ChangedWhen { get; set; } } \ No newline at end of file diff --git a/src/ReC.Infrastructure/RecDbContext.cs b/src/ReC.Infrastructure/RecDbContext.cs index b13ca0d..0af7808 100644 --- a/src/ReC.Infrastructure/RecDbContext.cs +++ b/src/ReC.Infrastructure/RecDbContext.cs @@ -139,6 +139,29 @@ public class RecDbContext(DbContextOptions options) : DbContext(op b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN"); }); + modelBuilder.Entity(b => + { + b.ToTable("TBREC_CFG_PROFILE", "dbo"); + + b.HasKey(e => e.Id); + + b.Property(e => e.Id) + .HasColumnName("GUID") + .ValueGeneratedOnAdd(); + + b.Property(e => e.Active).HasColumnName("ACTIVE"); + b.Property(e => e.Type).HasColumnName("TYPE"); + b.Property(e => e.Mandantor).HasColumnName("MANDANTOR"); + b.Property(e => e.Name).HasColumnName("PROFILE_NAME"); + b.Property(e => e.Description).HasColumnName("DESCRIPTION"); + b.Property(e => e.LogLevel).HasColumnName("LOG_LEVEL"); + b.Property(e => e.Language).HasColumnName("LANGUAGE"); + b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO"); + b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN"); + b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO"); + b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN"); + }); + modelBuilder.Entity(b => { b.ToTable("VWREC_ACTION", "dbo");