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.
This commit is contained in:
2025-12-10 12:02:20 +01:00
parent b326e7e1b3
commit 674c14dd7c
2 changed files with 24 additions and 19 deletions

View File

@@ -1,46 +1,28 @@
using System.ComponentModel.DataAnnotations; namespace ReC.Domain.Entities;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
[Table("TBREC_CFG_PROFILE", Schema = "dbo")]
public class Profile public class Profile
{ {
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public long Id { get; set; } public long Id { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; } public bool? Active { get; set; }
[Column("TYPE")]
public string? Type { get; set; } public string? Type { get; set; }
[Column("MANDANTOR")]
public string? Mandantor { get; set; } public string? Mandantor { get; set; }
[Column("PROFILE_NAME")]
public string? Name { get; set; } public string? Name { get; set; }
[Column("DESCRIPTION")]
public string? Description { get; set; } public string? Description { get; set; }
[Column("LOG_LEVEL")]
public string? LogLevel { get; set; } public string? LogLevel { get; set; }
[Column("LANGUAGE")]
public string? Language { get; set; } public string? Language { get; set; }
[Column("ADDED_WHO")]
public string? AddedWho { get; set; } public string? AddedWho { get; set; }
[Column("ADDED_WHEN")]
public DateTime? AddedWhen { get; set; } public DateTime? AddedWhen { get; set; }
[Column("CHANGED_WHO")]
public string? ChangedWho { get; set; } public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN")]
public DateTime? ChangedWhen { get; set; } public DateTime? ChangedWhen { get; set; }
} }

View File

@@ -139,6 +139,29 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN"); b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
}); });
modelBuilder.Entity<Profile>(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<RecActionView>(b => modelBuilder.Entity<RecActionView>(b =>
{ {
b.ToTable("VWREC_ACTION", "dbo"); b.ToTable("VWREC_ACTION", "dbo");