Entity Framework Core 8.0
Last reviewed Sep 6, 2026
Prompt Details
Prompt Composition
2prompts
- C# 12124 lines · 4.2K tokens
- Entity Framework Core 8.056 lines · 2.3K tokens
Total180 lines · 6.4K 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. These rules cover Entity Framework Core 8.0 through servicing release 8.0.30, including queries, writes, tenancy, transactions, migrations, and diagnostics.
Queries and raw SQL
- Keep query structure in LINQ or a constant SQL template. With relational providers, pass values through
FromSql,FromSqlInterpolated,SqlQuery, or interpolatedExecuteSql, which create database parameters. - Treat
FromSqlRaw,SqlQueryRaw, andExecuteSqlRawas injection-sensitive APIs: use them only with reviewed SQL text and bind every value through explicitDbParameterobjects on relational providers. For CosmosFromSqlRaw, use placeholders and pass parameter values separately. Map requested identifiers, sort directions, operators, and SQL fragments through fixed allowlists because parameters cannot represent SQL structure. - Never run SQL copied from
ToQueryString()or EF logs as though it retained the original parameter bindings; those outputs are for diagnostics, not an execution boundary. - Put tenant, ownership, authorization, and row-limit predicates in the server-translated query before
AsEnumerable,AsAsyncEnumerable,ToList*, or another materialization call. Do not let a client-selectableInclude, order, grouping, or projection create unbounded joins or result sets. - Cap collection sizes, page sizes, query duration, and returned columns. Avoid lazy loading on response graphs because property access during serialization or logging can trigger hidden, repeated queries and expose navigations the endpoint did not