23 lines
737 B
C#
23 lines
737 B
C#
using BlueLaminate.EFCore.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace BlueLaminate.EFCore.Configurations;
|
|
|
|
public class InventoryItemConfiguration : IEntityTypeConfiguration<InventoryItem>
|
|
{
|
|
public void Configure(EntityTypeBuilder<InventoryItem> entity)
|
|
{
|
|
// A Steam asset id identifies one physical copy; never store it twice.
|
|
entity.HasIndex(e => e.AssetId).IsUnique();
|
|
|
|
entity.HasOne(e => e.User)
|
|
.WithMany(u => u.InventoryItems)
|
|
.HasForeignKey(e => e.UserId);
|
|
|
|
entity.HasOne(e => e.SkinInstance)
|
|
.WithMany(i => i.InventoryItems)
|
|
.HasForeignKey(e => e.SkinInstanceId);
|
|
}
|
|
}
|