configure-trim-safe-efcore — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited configure-trim-safe-efcore (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Entity Framework Core relies heavily on runtime reflection and dynamic code compilation to discover model schemas and execute LINQ queries. In trimmed Blazor WebAssembly applications, reflection causes massive WASM payload sizes and introduces runtime crash risks when the IL Linker strips out internal C# entity properties.
This skill provides a systematic workflow to optimize and configure EF Core for reflection-free builds, ensuring safety and minimal payloads in trimmed Blazor WebAssembly projects.
Before executing this workflow, the agent needs:
.csproj configured for publishing with trimming (<PublishTrimmed>true</PublishTrimmed>)..NET WebAssembly build tools workload on the system.Instead of compiling LINQ queries dynamically at runtime, generate static interceptors:
dotnet ef dbcontext optimize --output-dir Persistence/CompiledModels --namespace YourApp.CompiledModelsProgram.cs to use the precompiled model: options.UseModel(YourApp.CompiledModels.ContestDbContextModel.Instance);Checkpoint: Ensure `Persistence/CompiledModels` is populated with CompiledModel files.
To prevent reflection crashes during Entity serialization (common when saving SQLite backups or parsing JSON payloads):
JsonSerializerContext and mark all your database entities as serializable: [JsonSerializable(typeof(CategoryEntity))]
[JsonSerializable(typeof(EntryEntity))]
[JsonSerializable(typeof(RelationEntity))]
public partial class EntityJsonContext : JsonSerializerContext { } var rawBase64 = JsonSerializer.Deserialize(raw, typeof(string), EntityJsonContext.Default);Checkpoint: All JSON operations on entities are resolved statically at compile time.
If third-party assemblies throw linker warnings during publish, declare explicit preservation rules:
LinkerConfig.xml file at the project root. <linker>
<assembly fullname="ContestJudging.Core">
<type fullname="ContestJudging.Core.Entities.*" preserve="all" />
</assembly>
</linker>.csproj: <ItemGroup>
<IllinkImportDescriptor Include="LinkerConfig.xml" />
</ItemGroup>Checkpoint: Critical database model structures are protected from being stripped by the trimmer.
To verify the trimming configurations are correct:
dotnet publish -c ReleaseIL2026 or IL2111 warnings during publish evaluation.| Pitfall | Why It Fails | Correct Approach |
|---|---|---|
Suppressing warnings using [UnconditionalSuppressMessage] | It hides warnings but does not prevent the trimmer from stripping models, leading to NullReferenceException at runtime. | Implement compile-time model precompilation and source serialization contexts instead. |
| Using dynamic runtime queries | Trimming strips methods needed to evaluate dynamic query expressions. | Rely solely on statically analyzable LINQ queries. |
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.