Change to static skin catalog population
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using BlueLaminate.EFCore.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace BlueLaminate.EFCore.Configurations;
|
||||
|
||||
public class CollectionConfiguration : IEntityTypeConfiguration<Collection>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Collection> entity)
|
||||
{
|
||||
// Slug is the natural key the sync upserts against.
|
||||
entity.HasIndex(e => e.Slug).IsUnique();
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,27 @@ public class SkinConfiguration : IEntityTypeConfiguration<Skin>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Skin> entity)
|
||||
{
|
||||
entity.Property(e => e.FloatMin)
|
||||
.HasColumnType("numeric(10,9)")
|
||||
.HasDefaultValue(0.0m);
|
||||
entity.Property(e => e.FloatMax)
|
||||
.HasColumnType("numeric(10,9)")
|
||||
.HasDefaultValue(1.0m);
|
||||
// Nullable: null means the catalogue gives no wear range (e.g. vanilla
|
||||
// knives), distinct from a genuine 0.0–1.0 range.
|
||||
entity.Property(e => e.FloatMin).HasColumnType("numeric(10,9)");
|
||||
entity.Property(e => e.FloatMax).HasColumnType("numeric(10,9)");
|
||||
|
||||
entity.Property(e => e.TrueFloat)
|
||||
.HasComputedColumnSql("float_min = 0.0 AND float_max = 1.0", stored: true);
|
||||
|
||||
entity.HasIndex(e => e.TrueFloat);
|
||||
|
||||
// Slug is the natural key the sync upserts against.
|
||||
entity.HasIndex(e => e.Slug).IsUnique();
|
||||
|
||||
entity.HasOne(e => e.Weapon)
|
||||
.WithMany(w => w.Skins)
|
||||
.HasForeignKey(e => e.WeaponId);
|
||||
|
||||
// A skin can come from many collections and containers, and each of those
|
||||
// holds many skins.
|
||||
entity.HasMany(e => e.Collections)
|
||||
.WithMany(c => c.Skins)
|
||||
.UsingEntity(join => join.ToTable("skin_collections"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user