Refactor Connection entity to use Fluent API mapping

Removed data annotations from Connection.cs and moved all table and column mapping to RecDbContext's OnModelCreating using the Fluent API. This centralizes entity configuration and removes dependencies on DataAnnotations in the entity class.
This commit is contained in:
2025-12-10 11:56:14 +01:00
parent 8bc9b85049
commit 13346b610a
2 changed files with 26 additions and 21 deletions

View File

@@ -30,6 +30,31 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Connection>(b =>
{
b.ToTable("TBDD_CONNECTION");
b.HasKey(e => e.Id);
b.Property(e => e.Id)
.HasColumnName("GUID")
.ValueGeneratedOnAdd();
b.Property(e => e.Bezeichnung).HasColumnName("BEZEICHNUNG");
b.Property(e => e.SqlProvider).HasColumnName("SQL_PROVIDER");
b.Property(e => e.Server).HasColumnName("SERVER");
b.Property(e => e.Datenbank).HasColumnName("DATENBANK");
b.Property(e => e.Username).HasColumnName("USERNAME");
b.Property(e => e.Password).HasColumnName("PASSWORD");
b.Property(e => e.Bemerkung).HasColumnName("BEMERKUNG");
b.Property(e => e.Aktiv).HasColumnName("AKTIV");
b.Property(e => e.ErstelltWer).HasColumnName("ERSTELLTWER");
b.Property(e => e.ErstelltWann).HasColumnName("ERSTELLTWANN");
b.Property(e => e.GeandertWer).HasColumnName("GEANDERTWER");
b.Property(e => e.GeaendertWann).HasColumnName("GEAENDERTWANN");
b.Property(e => e.SysConnection).HasColumnName("SYS_CONNECTION");
});
modelBuilder.Entity<EndpointParam>(b =>
{
b.ToTable("TBREC_CFG_ENDPOINT_PARAMS", "dbo");