Working on Networking
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Server.Data;
|
||||
|
||||
public sealed class EquipmentSlot
|
||||
{
|
||||
public ulong Id { get; set; }
|
||||
public ulong CharacterId { get; set; }
|
||||
public byte SlotCode { get; set; } // 1=head,2=chest,...
|
||||
public ulong ItemTemplateId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
public Character? Character { get; set; }
|
||||
public ItemTemplate? ItemTemplate { get; set; }
|
||||
}
|
||||
|
||||
public sealed class EquipmentSlotConfig : IEntityTypeConfiguration<EquipmentSlot>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<EquipmentSlot> e)
|
||||
{
|
||||
e.ToTable("equipment");
|
||||
e.HasKey(x => x.Id);
|
||||
e.Property(x => x.Id).ValueGeneratedOnAdd();
|
||||
e.HasIndex(x => new { x.CharacterId, x.SlotCode }).IsUnique();
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
|
||||
e.HasOne(x => x.Character).WithMany().HasForeignKey(x => x.CharacterId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(x => x.ItemTemplate).WithMany().HasForeignKey(x => x.ItemTemplateId).OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user