Initial project
This commit is contained in:
57
src/Data/Models/AppSetting.cs
Normal file
57
src/Data/Models/AppSetting.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace SoaFE.Portal.Data.Models;
|
||||
|
||||
public sealed class AppSetting : IEntityTypeConfiguration<AppSetting>
|
||||
{
|
||||
#region Scalar Properties
|
||||
|
||||
public required string AppSettingKey { get; set; }
|
||||
public JsonElement? Value { get; set; }
|
||||
public DateTimeOffset? ModifiedAt { get; set; }
|
||||
public long? ModifiedBy { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Navigation Properties
|
||||
|
||||
public User? ModifiedByUser { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public void Configure(EntityTypeBuilder<AppSetting> builder)
|
||||
{
|
||||
// Configure Table
|
||||
builder.ToTable("app_setting");
|
||||
builder.HasKey(e => e.AppSettingKey)
|
||||
.HasName("pk_app_setting");
|
||||
builder.HasIndex(e => e.ModifiedBy)
|
||||
.HasDatabaseName("ix_app_setting_modified_by");
|
||||
|
||||
// Configure Columns
|
||||
var order = 0;
|
||||
builder.Property(e => e.AppSettingKey)
|
||||
.HasColumnName("app_setting_key")
|
||||
.HasMaxLength(16)
|
||||
.HasColumnOrder(order++);
|
||||
builder.Property(e => e.Value)
|
||||
.HasColumnName("value")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnOrder(order++);
|
||||
builder.Property(e => e.ModifiedAt)
|
||||
.HasColumnName("modified_at")
|
||||
.HasColumnOrder(order++);
|
||||
builder.Property(e => e.ModifiedBy)
|
||||
.HasColumnName("modified_by")
|
||||
.HasColumnOrder(order++);
|
||||
|
||||
// Configure Relationships
|
||||
builder.HasOne(e => e.ModifiedByUser)
|
||||
.WithMany()
|
||||
.HasForeignKey(e => e.ModifiedBy)
|
||||
.HasConstraintName("fk_app_setting_user_modified_by")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user