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:
@@ -1,52 +1,32 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
namespace ReC.Domain.Entities;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace ReC.Domain.Entities;
|
|
||||||
|
|
||||||
[Table("TBDD_CONNECTION")]
|
|
||||||
public class Connection
|
public class Connection
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
||||||
[Column("GUID")]
|
|
||||||
public short? Id { get; set; }
|
public short? Id { get; set; }
|
||||||
|
|
||||||
[Column("BEZEICHNUNG")]
|
|
||||||
public string? Bezeichnung { get; set; }
|
public string? Bezeichnung { get; set; }
|
||||||
|
|
||||||
[Column("SQL_PROVIDER")]
|
|
||||||
public string? SqlProvider { get; set; }
|
public string? SqlProvider { get; set; }
|
||||||
|
|
||||||
[Column("SERVER")]
|
|
||||||
public string? Server { get; set; }
|
public string? Server { get; set; }
|
||||||
|
|
||||||
[Column("DATENBANK")]
|
|
||||||
public string? Datenbank { get; set; }
|
public string? Datenbank { get; set; }
|
||||||
|
|
||||||
[Column("USERNAME")]
|
|
||||||
public string? Username { get; set; }
|
public string? Username { get; set; }
|
||||||
|
|
||||||
[Column("PASSWORD")]
|
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
[Column("BEMERKUNG")]
|
|
||||||
public string? Bemerkung { get; set; }
|
public string? Bemerkung { get; set; }
|
||||||
|
|
||||||
[Column("AKTIV")]
|
|
||||||
public bool? Aktiv { get; set; }
|
public bool? Aktiv { get; set; }
|
||||||
|
|
||||||
[Column("ERSTELLTWER")]
|
|
||||||
public string? ErstelltWer { get; set; }
|
public string? ErstelltWer { get; set; }
|
||||||
|
|
||||||
[Column("ERSTELLTWANN")]
|
|
||||||
public DateTime? ErstelltWann { get; set; }
|
public DateTime? ErstelltWann { get; set; }
|
||||||
|
|
||||||
[Column("GEANDERTWER")]
|
|
||||||
public string? GeandertWer { get; set; }
|
public string? GeandertWer { get; set; }
|
||||||
|
|
||||||
[Column("GEAENDERTWANN")]
|
|
||||||
public DateTime? GeaendertWann { get; set; }
|
public DateTime? GeaendertWann { get; set; }
|
||||||
|
|
||||||
[Column("SYS_CONNECTION")]
|
|
||||||
public bool? SysConnection { get; set; }
|
public bool? SysConnection { get; set; }
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,31 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
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 =>
|
modelBuilder.Entity<EndpointParam>(b =>
|
||||||
{
|
{
|
||||||
b.ToTable("TBREC_CFG_ENDPOINT_PARAMS", "dbo");
|
b.ToTable("TBREC_CFG_ENDPOINT_PARAMS", "dbo");
|
||||||
|
|||||||
Reference in New Issue
Block a user