using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Server.Data; public sealed class ItemTemplate { public ulong Id { get; set; } public string Name { get; set; } = ""; public byte ItemType { get; set; } = 1; public byte Rarity { get; set; } = 1; public uint MaxStack { get; set; } = 1; public uint Weight { get; set; } = 0; public string? StatsJson { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } } public sealed class ItemTemplateConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder e) { e.ToTable("item_templates"); e.HasKey(x => x.Id); e.Property(x => x.Id).ValueGeneratedOnAdd(); e.Property(x => x.Name).HasMaxLength(64).IsRequired(); e.HasIndex(x => x.Name).IsUnique(); e.Property(x => x.StatsJson).HasColumnType("json"); e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)"); e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)") .ValueGeneratedOnAddOrUpdate(); } }