25 lines
780 B
C#
25 lines
780 B
C#
using BlueLaminate.EFCore.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace BlueLaminate.EFCore.Configurations;
|
|
|
|
public class PriceHistoryConfiguration : IEntityTypeConfiguration<PriceHistory>
|
|
{
|
|
public void Configure(EntityTypeBuilder<PriceHistory> entity)
|
|
{
|
|
entity.Property(e => e.Price).HasPrecision(18, 2);
|
|
|
|
entity.HasIndex(e => new { e.SkinId, e.ConditionId, e.RecordedAt });
|
|
|
|
entity.HasOne(e => e.Skin)
|
|
.WithMany(s => s.PriceHistories)
|
|
.HasForeignKey(e => e.SkinId);
|
|
|
|
entity.HasOne(e => e.Condition)
|
|
.WithMany(c => c.PriceHistories)
|
|
.HasForeignKey(e => e.ConditionId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
}
|
|
}
|