CI's Formatting job failed: 19 touched files carried a BOM, which .editorconfig forbids (charset=utf-8). Pure encoding change — one byte per file, no semantic diff (verified: every hunk is `-namespace` -> `+namespace`). Self-inflicted. The patches that edited these legacy files wrote them back as utf-8-sig to "preserve the existing style", but the #311 fix-as-you-touch gate requires a file to be normalized when you touch it — that is the whole point of scoping the gate to changed files instead of reformatting the ~2500 legacy BOM files at once. dotnet format leaves the EF-generated Designer/snapshot files alone as generated code, and its verify skips them the same way, so they stay as ef emitted them. Two corrections to what I believed going in: - `dotnet format --include` does NOT no-op here. It reported `error CHARSET` for each file and exit 2, reproducing CI exactly, and fixed them in place. The note claiming otherwise is wrong for this invocation. - My first BOM check reported all files clean. The od pattern was wrong; reading the first three bytes directly found 19. A detector that can only say "ok" is worse than no detector. Core.Tests 565, ErsatzTV.Tests 1673, Architecture.Tests 5 — all passed. API artifacts still in sync. Refs #70 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63 lines
2.6 KiB
C#
63 lines
2.6 KiB
C#
using ErsatzTV.Core.Domain;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace ErsatzTV.Infrastructure.Data.Configurations;
|
|
|
|
public class MultiCollectionConfiguration : IEntityTypeConfiguration<MultiCollection>
|
|
{
|
|
public void Configure(EntityTypeBuilder<MultiCollection> builder)
|
|
{
|
|
builder.ToTable("MultiCollection");
|
|
|
|
builder.Property(mc => mc.Version).IsConcurrencyToken();
|
|
|
|
builder.Property(mc => mc.Name)
|
|
.HasMaxLength(50)
|
|
.HasColumnType("varchar(50)");
|
|
|
|
builder.HasIndex(mc => mc.Name)
|
|
.IsUnique();
|
|
|
|
builder.HasMany(m => m.Collections)
|
|
.WithMany(m => m.MultiCollections)
|
|
.UsingEntity<MultiCollectionItem>(
|
|
j => j.HasOne(mci => mci.Collection)
|
|
.WithMany(c => c.MultiCollectionItems)
|
|
.HasForeignKey(mci => mci.CollectionId)
|
|
.OnDelete(DeleteBehavior.Cascade),
|
|
j => j.HasOne(mci => mci.MultiCollection)
|
|
.WithMany(mc => mc.MultiCollectionItems)
|
|
.HasForeignKey(mci => mci.MultiCollectionId)
|
|
.OnDelete(DeleteBehavior.Cascade),
|
|
j =>
|
|
{
|
|
j.HasKey(mci => new { mci.MultiCollectionId, mci.CollectionId });
|
|
|
|
// default 1 = fair share (#70). Must be a DB default too: existing rows would
|
|
// otherwise migrate to 0, and a 0-weight source is dropped by the enumerator.
|
|
j.Property(mci => mci.Weight).HasDefaultValue(1);
|
|
});
|
|
|
|
builder.HasMany(m => m.SmartCollections)
|
|
.WithMany(m => m.MultiCollections)
|
|
.UsingEntity<MultiCollectionSmartItem>(
|
|
j => j.HasOne(mci => mci.SmartCollection)
|
|
.WithMany(c => c.MultiCollectionSmartItems)
|
|
.HasForeignKey(mci => mci.SmartCollectionId)
|
|
.OnDelete(DeleteBehavior.Cascade),
|
|
j => j.HasOne(mci => mci.MultiCollection)
|
|
.WithMany(mc => mc.MultiCollectionSmartItems)
|
|
.HasForeignKey(mci => mci.MultiCollectionId)
|
|
.OnDelete(DeleteBehavior.Cascade),
|
|
j =>
|
|
{
|
|
j.HasKey(mci => new { mci.MultiCollectionId, mci.SmartCollectionId });
|
|
|
|
// mirrors MultiCollectionItem above -- omitting it would silently un-weight
|
|
// every smart-collection member of a multi collection
|
|
j.Property(mci => mci.Weight).HasDefaultValue(1);
|
|
});
|
|
}
|
|
}
|