Files
Operation-Blue-Laminate-v2/BlueLaminate/BlueLaminate.EFCore/Configurations/SkinConfiguration.cs

35 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BlueLaminate.EFCore.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace BlueLaminate.EFCore.Configurations;
public class SkinConfiguration : IEntityTypeConfiguration<Skin>
{
public void Configure(EntityTypeBuilder<Skin> entity)
{
// Nullable: null means the catalogue gives no wear range (e.g. vanilla
// knives), distinct from a genuine 0.01.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"));
}
}