All examples

ASP.NET Core Razor Pages + EF Core

Server-rendered .NET 10 web app with Razor Pages, EF Core on SQL Server, and xUnit page tests.

Composed from the dotnet-razor-pages rules pack. Same file from the CLI: aibysitter init --packs dotnet-razor-pages --format claude

Written for this site, CC0, scored by this linter, not tested against any agent.

File
CLAUDE.md, 44 lines
Format
CLAUDE.md
Save as
CLAUDE.md
Category
.NET
Tags
License
CC0 1.0, public domain. No attribution needed.

Download CLAUDE.md Lint a copy

Aibysitter lint score

100 / 100 — A

Ruleset v4

No deductions.

Badge

Aibysitter lint score: A 100

Markdown for a README:

[![Aibysitter lint score: A 100](https://aibysitting.net/gallery/dotnet-razor-pages/badge.svg)](https://aibysitting.net/Gallery/dotnet-razor-pages)

CLAUDE.md

View rendered

  1. # ASP.NET Core Razor Pages
  2. ASP.NET Core Razor Pages on .NET 10. EF Core 10 with SQL Server. Serilog for logging. xUnit for tests.
  3. ## Layout
  4. - `src/<App>.Web`: Razor Pages, page models, `Program.cs`.
  5. - `src/<App>.Data`: `<App>DbContext`, entity configurations, migrations.
  6. - `tests/<App>.Web.Tests`: xUnit page tests using `WebApplicationFactory<Program>`.
  7. - `tests/<App>.Data.Tests`: xUnit data tests against SQL Server.
  8. ## Commands
  9. - Build: `dotnet build <App>.slnx -warnaserror`
  10. - Test: `dotnet test <App>.slnx`
  11. - Run: `dotnet run --project src/<App>.Web`
  12. - New migration: `dotnet ef migrations add <Name> --project src/<App>.Data --startup-project src/<App>.Web`
  13. ## Pages
  14. - One page per file pair: `Pages/<Area>/<Name>.cshtml` and `<Name>.cshtml.cs`.
  15. - Page models take dependencies through the primary constructor.
  16. - Bind form input with `[BindProperty]` on a dedicated input record. Entities are never bound directly.
  17. - Validate with data annotations. Return `Page()` when `ModelState` is invalid.
  18. - A successful POST handler ends with `RedirectToPage(...)`.
  19. - No JavaScript in pages unless the task asks for it.
  20. ## Data access
  21. - Read-only queries use `AsNoTracking()`.
  22. - Load related data with explicit `Include` calls. Lazy loading is disabled.
  23. - One `SaveChangesAsync` call per POST handler.
  24. - Schema changes go through a new migration. Do not edit a migration that has been applied.
  25. - Connection strings come from user-secrets locally and environment variables on the server. `appsettings.json` holds no secrets.
  26. ## Logging
  27. - Use `ILogger<T>` with message templates: `logger.LogInformation("Order {OrderId} shipped", order.Id)`.
  28. - Do not log email addresses, names, or payment details.
  29. ## Tests
  30. - Every new page gets a test that requests it through `WebApplicationFactory<Program>` and asserts the status code and one piece of rendered text.
  31. - Data tests use the SQL Server container started by `tests/<App>.Data.Tests/DatabaseFixture.cs`.
  32. - Every test asserts a result. A test that calls a method without an assertion is incomplete.
  33. ## Done
  34. - `dotnet build -warnaserror` passes.
  35. - `dotnet test` passes.
  36. - Changed files are limited to the ones the task names, plus their tests and migrations.