Entity Framework Core 9.0
Last reviewed Sep 6, 2026
Prompt Details
Prompt Composition
2prompts
- C# 12124 lines · 4.2K tokens
- Entity Framework Core 9.064 lines · 2.5K tokens
Total188 lines · 6.7K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 89
- 94
- 117
- 190
- 201
- 208
- 209
- 214
- 250
- 257
- 295
- 319
- 323
- 327
- 338
- 362
- 367
- 378
- 426
- 488
- 502
- 532
- 639
- 674
- 759
- 770
- 772
- 775
- 798
- 862
- 915
- 916
- 918
- 923
- 1333
- 1395
Prompt Preview
Apply the C# 12 and .NET 8 baseline first. EF Core 9 targets .NET 8 and can run on .NET 8 or .NET 9; these rules cover servicing release 9.0.19.
Query construction and resource use
- Prefer LINQ and the parameterizing
FromSql,FromSqlInterpolated,SqlQuery, and interpolatedExecuteSqlAPIs. For Cosmos queries in EF9, useFromSqlrather than composing request values intoFromSqlRaw. - For relational queries and commands, allow
FromSqlRaw,SqlQueryRaw, orExecuteSqlRawonly behind a narrow adapter whose SQL structure is fixed or selected from an allowlist and whose values are explicitDbParameterinstances. Parameterization cannot make an attacker-chosen identifier, ordering token, operator, or provider command safe. - Never execute text copied from
ToQueryString()or diagnostic logs; it is display-oriented SQL and does not preserve the original safe bindings. - Apply tenant, resource authorization, filtering, ordering, and row limits while the expression is still server-translatable. Calls such as
AsEnumerable,AsAsyncEnumerable, orToList*move later work to the process and can turn a selective query into data exposure or denial of service. - Bound page size, primitive-collection length, projected columns, includes, retries, and query time. Prefer explicit projections and loading; lazy-loading during serialization, mapping, or logging can issue unreviewed N+1 queries and traverse unauthorized navigations.
- Keep parameterized collections as the default. Use
EF.Constant,EF.Parameter,TranslateParameterizedCollectionsToConstants, or