Refactor RecAction mapping to Fluent API in DbContext
Moved all RecAction table and column mappings from data annotations in the entity class to Fluent API configuration in RecDbContext. Also consolidated the OutRes relationship setup into the new configuration block, removing redundant mapping code. RecAction is now a plain class without EF attributes.
This commit is contained in:
@@ -162,6 +162,36 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RecAction>(b =>
|
||||
{
|
||||
b.ToTable("TBREC_CFG_ACTION");
|
||||
|
||||
b.HasKey(e => e.Id);
|
||||
|
||||
b.Property(e => e.Id).HasColumnName("GUID");
|
||||
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
|
||||
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||
b.Property(e => e.Sequence).HasColumnName("SEQUENCE");
|
||||
b.Property(e => e.EndpointId).HasColumnName("ENDPOINT_ID");
|
||||
b.Property(e => e.EndpointAuthId).HasColumnName("ENDPOINT_AUTH_ID");
|
||||
b.Property(e => e.EndpointParamsId).HasColumnName("ENDPOINT_PARAMS_ID");
|
||||
b.Property(e => e.SqlConnectionId).HasColumnName("SQL_CONNECTION_ID");
|
||||
b.Property(e => e.Type).HasColumnName("TYPE");
|
||||
b.Property(e => e.PreprocessingQuery).HasColumnName("PREPROCESSING_QUERY");
|
||||
b.Property(e => e.HeaderQuery).HasColumnName("HEADER_QUERY");
|
||||
b.Property(e => e.BodyQuery).HasColumnName("BODY_QUERY");
|
||||
b.Property(e => e.PostprocessingQuery).HasColumnName("POSTPROCESSING_QUERY");
|
||||
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");
|
||||
|
||||
b.HasOne(act => act.OutRes)
|
||||
.WithOne(res => res.Action)
|
||||
.HasForeignKey<OutRes>(res => res.ActionId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RecActionView>(b =>
|
||||
{
|
||||
b.ToTable("VWREC_ACTION", "dbo");
|
||||
@@ -209,10 +239,5 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
b.Property(e => e.RawBody).HasColumnName("REQUEST_BODY");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RecAction>()
|
||||
.HasOne(act => act.OutRes)
|
||||
.WithOne(res => res.Action)
|
||||
.HasForeignKey<OutRes>(res => res.ActionId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user