using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; namespace SlpModularCms.Modules.Hero.Data; /// /// Where the hero's photos are stored (media library phase 3b). Off (default): the hero's own table HeroImages. On /// (Media__Library__HeroPhotosInLibrary=true): the library's MediaAssets table (rows of module hero), with /// HeroImages kept up to date as a safety net so the switch can go back. The choice is made when the application starts. /// public sealed record HeroStorage(bool PhotosInLibrary); /// EF builds the model once per key: the two storage modes have different models. public sealed class HeroModelCacheKeyFactory : IModelCacheKeyFactory { public object Create(DbContext context, bool designTime) => (context.GetType(), context is HeroDbContext { PhotosInLibrary: true }, designTime); }