28 lines
850 B
C#
28 lines
850 B
C#
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)
|
|
{
|
|
entity.Property(e => e.FloatMin)
|
|
.HasColumnType("numeric(10,9)")
|
|
.HasDefaultValue(0.0m);
|
|
entity.Property(e => e.FloatMax)
|
|
.HasColumnType("numeric(10,9)")
|
|
.HasDefaultValue(1.0m);
|
|
|
|
entity.Property(e => e.TrueFloat)
|
|
.HasComputedColumnSql("float_min = 0.0 AND float_max = 1.0", stored: true);
|
|
|
|
entity.HasIndex(e => e.TrueFloat);
|
|
|
|
entity.HasOne(e => e.Weapon)
|
|
.WithMany(w => w.Skins)
|
|
.HasForeignKey(e => e.WeaponId);
|
|
}
|
|
}
|