Move Endpoint entity config to Fluent API in DbContext

Removed data annotations from Endpoint class and defined its table, key, and column mappings using Fluent API in RecDbContext. This centralizes entity configuration and improves code maintainability.
This commit is contained in:
2025-12-10 11:58:42 +01:00
parent 13346b610a
commit 3f8ba7d76c
2 changed files with 20 additions and 15 deletions

View File

@@ -1,34 +1,20 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ReC.Domain.Entities;
namespace ReC.Domain.Entities;
[Table("TBREC_CFG_ENDPOINT")]
public class Endpoint
{
[Key]
[Column("GUID")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[Column("ACTIVE")]
public bool? Active { get; set; }
[Column("DESCRIPTION")]
public string? Description { get; set; }
[Column("URI")]
public string? Uri { 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; }
}

View File

@@ -55,6 +55,25 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
b.Property(e => e.SysConnection).HasColumnName("SYS_CONNECTION");
});
modelBuilder.Entity<Endpoint>(b =>
{
b.ToTable("TBREC_CFG_ENDPOINT");
b.HasKey(e => e.Id);
b.Property(e => e.Id)
.HasColumnName("GUID")
.ValueGeneratedOnAdd();
b.Property(e => e.Active).HasColumnName("ACTIVE");
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
b.Property(e => e.Uri).HasColumnName("URI");
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<EndpointParam>(b =>
{
b.ToTable("TBREC_CFG_ENDPOINT_PARAMS", "dbo");