Minimal APIs, Nullable aktiviert, geprüfte EF-Core-Migrationen, ProblemDetails-Fehler.
Constitution — ASP.NET Core API
Version 1.0.0 · Ratified 2026-11-10
These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.
-
Minimal APIs. Endpoints are minimal APIs grouped per feature with
MapGroupand declared in one extension method per feature. Handlers returnTypedResultsso the OpenAPI document knows every response. -
Nullable enabled.
<Nullable>enable</Nullable>and<TreatWarningsAsErrors>true</TreatWarningsAsErrors>are set inDirectory.Build.props. The null-forgiving operator!needs a reason in the review. -
EF Core migrations reviewed. Every model change ships its migration and the generated SQL script (
dotnet ef migrations script --idempotent) in the same pull request. Migrations run as a deploy step, never throughDatabase.Migrate()at app startup. -
ProblemDetails errors.
AddProblemDetailsand anIExceptionHandlermap domain errors to RFC 9457 responses with a stabletype. Exception messages and stack traces never reach the client outside development. -
Async with cancellation. Every I/O method is async and takes the request’s
CancellationTokendown to EF Core andHttpClient..Resultand.Wait()fail the review. -
Validated input. Request DTOs are records validated (FluentValidation or the built-in validation) before the handler runs; failures return a
ValidationProblem. Entities are never bound from or returned to the client. -
Options pattern for config. Settings bind to classes with
AddOptions<T>().Bind(...).ValidateDataAnnotations().ValidateOnStart(). NoIConfiguration["key"]reads inside services. -
Integration tests. Each endpoint has tests with
WebApplicationFactoryagainst a real database in Testcontainers, covering success, a validation problem and unauthorized access.