Framework cheatsheet
.NET and ASP.NET Core 10 Cheatsheet
The dotnet CLI for creating, building, testing and publishing projects, plus common ASP.NET Core and EF Core code.
Setup and info
- Check the SDK version — Print the version of the .NET SDK in use.
- List installed SDKs — Show every installed SDK version.
- Show full environment info — Print SDKs, runtimes and OS details. Useful for bug reports.
- List project templates — Show the templates you can create projects from.
- Trust the HTTPS development certificate — Create and trust a local certificate so https://localhost works without warnings.
Projects and solutions
- Create a web API — Create an ASP.NET Core web API project.
- Create a console app — Create a console application.
- Create a solution — Create a solution file to group projects.
- Add a project to a solution — Include a project in the solution.
- Add a .gitignore — Create a .gitignore suited to .NET projects.
- Add a NuGet package — Add a package reference to the project.
- Reference another project — Add a project-to-project reference.
- Find outdated packages — List packages that have newer versions.
Build, run and test
- Restore dependencies — Download the NuGet packages a project needs.
- Build the project — Compile the project or solution.
- Run the project — Build the project if needed and run it.
- Run with hot reload — Rebuild and restart when source files change.
- Run the tests — Run the tests in a project or solution.
- Run matching tests — Run only tests whose fully qualified name contains the text.
- Format the code — Apply code style rules to the project.
- Clean build output — Delete the bin and obj outputs of a build.
Publishing
- Publish for release — Build in Release mode and write the deployable files to a folder.
- Publish a self-contained app — Include the runtime, so the target machine needs no .NET install.
- Publish as a container image — Build a container image directly from the project, without a Dockerfile.
Entity Framework Core
- Install the EF tool — Install the dotnet ef command-line tool globally.
- Add a migration — Create a migration from model changes.
- Apply migrations — Update the database to the latest migration.
- Remove the last migration — Delete the most recent migration, if it has not been applied.
- Generate a SQL script — Write the SQL for all migrations to a file, for review or deployment.
- Register a DbContext — Add Entity Framework Core with PostgreSQL to dependency injection.
ASP.NET Core code
- Write a minimal API — Define endpoints without controllers.
- Register a service — Add a class to dependency injection with a scoped lifetime.
- Read configuration — Read a value from appsettings.json or an environment variable.
- Set up user secrets — Create a secrets store for development, kept outside your repository.
- Store a development secret — Save a secret value without putting it in appsettings.json. Use your own value.
- Add authentication and authorization — Order matters: authentication goes before authorization.
- Map controllers — Enable attribute-routed controllers.
Related cheatsheets
- Angular 22 cheatsheet — Angular CLI commands and standalone component, signals, template, routing, HTTP and forms snippets.
- Astro cheatsheet — Build fast content sites with Astro: components, layouts, routing, content collections, islands, endpoints and deployment.
- Django 6 cheatsheet — Create projects, run migrations, test and deploy Django apps, plus the ORM queries you use every day.
- Express 5 cheatsheet — Build HTTP servers and APIs with Express 5 on Node.js.
- FastAPI 0.115 cheatsheet — Install, run, test and deploy FastAPI apps from the command line.
- Flask 3 cheatsheet — Create, run, test and deploy Flask apps, with routes, templates, blueprints, sessions and database snippets.