diff --git a/src/csharp/LampControlApi/Infrastructure/Database/LampControlDbContext.cs b/src/csharp/LampControlApi/Infrastructure/Database/LampControlDbContext.cs
index 9b06f3e2..cb32fbe0 100644
--- a/src/csharp/LampControlApi/Infrastructure/Database/LampControlDbContext.cs
+++ b/src/csharp/LampControlApi/Infrastructure/Database/LampControlDbContext.cs
@@ -49,11 +49,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.CreatedAt)
.HasColumnName("created_at")
- .IsRequired();
+ .IsRequired()
+ .ValueGeneratedOnAdd();
entity.Property(e => e.UpdatedAt)
.HasColumnName("updated_at")
- .IsRequired();
+ .IsRequired()
+ .ValueGeneratedOnAddOrUpdate();
entity.Property(e => e.DeletedAt)
.HasColumnName("deleted_at");
diff --git a/src/csharp/LampControlApi/Infrastructure/Database/LampDbEntity.cs b/src/csharp/LampControlApi/Infrastructure/Database/LampDbEntity.cs
index 1b170178..9eb2eb5d 100644
--- a/src/csharp/LampControlApi/Infrastructure/Database/LampDbEntity.cs
+++ b/src/csharp/LampControlApi/Infrastructure/Database/LampDbEntity.cs
@@ -4,33 +4,35 @@ namespace LampControlApi.Infrastructure.Database
{
///
/// Database entity for the lamp table.
- /// Uses init setters for EF Core compatibility while maintaining immutability after construction.
+ /// Uses set accessors for EF Core compatibility to allow database-generated values.
///
public sealed record LampDbEntity
{
///
- /// Gets or initializes the unique identifier for the lamp.
+ /// Gets or sets the unique identifier for the lamp.
///
- public Guid Id { get; init; }
+ public Guid Id { get; set; }
///
- /// Gets a value indicating whether gets or initializes a value indicating whether the lamp is turned on (true) or off (false).
+ /// Gets or sets a value indicating whether the lamp is turned on (true) or off (false).
///
- public bool IsOn { get; init; }
+ public bool IsOn { get; set; }
///
- /// Gets or initializes the timestamp when the lamp was created.
+ /// Gets or sets the timestamp when the lamp was created.
+ /// Database-generated on insert.
///
- public DateTimeOffset CreatedAt { get; init; }
+ public DateTimeOffset CreatedAt { get; set; }
///
- /// Gets or initializes the timestamp when the lamp was last updated.
+ /// Gets or sets the timestamp when the lamp was last updated.
+ /// Database-generated on insert and update via trigger.
///
- public DateTimeOffset UpdatedAt { get; init; }
+ public DateTimeOffset UpdatedAt { get; set; }
///
- /// Gets or initializes the timestamp when the lamp was soft deleted, or null if active.
+ /// Gets or sets the timestamp when the lamp was soft deleted, or null if active.
///
- public DateTimeOffset? DeletedAt { get; init; }
+ public DateTimeOffset? DeletedAt { get; set; }
}
}