Add EF Core data annotations for table and FK mapping
Added [Table] and [ForeignKey] attributes to entity classes to explicitly map them to database tables/views and define relationships. Updated using directives as needed. Improves entity mapping clarity and robustness against schema changes.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
namespace ReC.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBDD_CONNECTION")]
|
||||
public class Connection
|
||||
{
|
||||
public short? Id { get; set; }
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace ReC.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBREC_CFG_ENDPOINT")]
|
||||
public class Endpoint
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using ReC.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBREC_CFG_ENDPOINT_AUTH")]
|
||||
public class EndpointAuth
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
namespace ReC.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the TBREC_CFG_ENDPOINT_PARAMS table.
|
||||
/// All properties are nullable to provide flexibility on the database side,
|
||||
/// preventing breaking changes if columns are altered to be nullable in production.
|
||||
/// </summary>
|
||||
[Table("TBREC_CFG_ENDPOINT_PARAMS", Schema = "dbo")]
|
||||
public class EndpointParam
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace ReC.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBREC_OUT_RESULT", Schema = "dbo")]
|
||||
public class OutRes
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace ReC.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBREC_CFG_PROFILE", Schema = "dbo")]
|
||||
public class Profile
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using ReC.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
|
||||
[Table("TBREC_CFG_ACTION")]
|
||||
public class RecAction
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using ReC.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Entities;
|
||||
@@ -12,14 +11,17 @@ namespace ReC.Domain.Entities;
|
||||
/// runtime mapping errors and ensures the application can handle schema changes without
|
||||
/// requiring immediate code updates.
|
||||
/// </summary>
|
||||
[Table("VWREC_ACTION", Schema = "dbo")]
|
||||
public class RecActionView
|
||||
{
|
||||
public required long Id { get; set; }
|
||||
|
||||
[ForeignKey("Id")]
|
||||
public RecAction? Root { get; set; }
|
||||
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
[ForeignKey("ProfileId")]
|
||||
public Profile? Profile { get; set; }
|
||||
|
||||
public string? ProfileName { get; set; }
|
||||
@@ -30,6 +32,9 @@ public class RecActionView
|
||||
|
||||
public long? EndpointId { get; set; }
|
||||
|
||||
[ForeignKey("EndpointId")]
|
||||
public Endpoint? Endpoint { get; set; }
|
||||
|
||||
public string? EndpointUri { get; set; }
|
||||
|
||||
public long? EndpointAuthId { get; set; }
|
||||
@@ -59,6 +64,9 @@ public class RecActionView
|
||||
|
||||
public short? SqlConnectionId { get; set; }
|
||||
|
||||
[ForeignKey("SqlConnectionId")]
|
||||
public Connection? SqlConnection { get; set; }
|
||||
|
||||
public string? SqlConnectionServer { get; set; }
|
||||
|
||||
public string? SqlConnectionDb { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user