JetBrains Rider 2023.2 Help

ASP.NET Scaffolding

Scaffolding is a tool that helps you quickly create controllers, views, and other items for your ASP.NET projects.

Add a new scaffolded item

  1. In the Solution Explorer, right-click the desired node and choose Add | New Scaffolded Item.

  2. In the popup that opens, select the type of the scaffolding that you want to add and enter a name for it.

  3. JetBrains Rider will add all necessary directories and files with the boilerplate code to your project.

JetBrains Rider provides the following scaffolded items:

Scaffolding option

Description

MVC Area

Scaffolds an Area Areas in ASP.NET MVC are a way to group related functionality together. Doing this allows views or Razor Pages to share a common folder structure and namespace for routing.

MVC Controller - Empty

Use this scaffold option when the controller needs to return only JSON or XML, or has another purpose. This scaffolded item contains a Controller class and an Index action method stub.

MVC Controller with read/write actions

Produces the same scaffolded output as MVC Controller – Empty, plus method stubs for all read/write actions, including methods for GET and POST requests.

MVC Controller with views, using Entity Framework

Creates everything you need for CRUD operations on a controller, including the controller itself with all the CRUD action methods (GET, POST, PUT), plus their associated views.

API Controller - Empty

Produces only a Controller class with attributes. This is the least amount of code possible, for example:

[Route("api/[controller]")] [ApiController] public class ApiEmptyController : ControllerBase { }

API Controller with read/write actions

Generates the skeleton code for GET, POST, and PUT operations for an API.

API Controller with views, using Entity Framework

Creates an API controller with full CRUD operations matching the GET, POST, and PUT HTTP methods, but it creates no views.

MVC View

Scaffolds a view. Make sure that you right-click the appropriate folder (Views/Home or Views/Shared) before selecting this option.

Razor Page

Use this option to create a simple Razor Page with or without a model. Be sure to right-click the appropriate folder, most often Pages\SubFolder, because scaffolding will create the page where you right-click. The scaffolding generates both the .cshtml and .cshtml.cs files.

Razor Page using Entity Framework

Use this option to create a Razor Page that connects to a database and have CRUD actions.

Razor Page using Entity Framework (CRUD)

This option creates the full set of CRUD pages: Create, Details, Delete, Edit, and Index. Don't forget to create the corresponding folder first for these Razor pages, then right-click that folder, so the pages are in the correct location.

Identity

Creates all the assets necessary for securing your ASP.NET application. With ASP.NET Core Identity, users of your apps can manage logins, passwords, profile data, roles, claims, tokens, and email confirmations. Identity scaffolding works in every kind of ASP.NET app — ASP.NET MVC, Razor Pages, ASP.NET Web API, and Blazor.

You'll need a DbContext that inherits from Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext defined in your project so that scaffolding creates assets that work specifically with ASP.NET Core Identity. The scaffolder creates an Areas folder with pages related to logins, as well as subfolders for account management.

For more information, refer to Scaffold Identity in ASP.NET Core projects on Microsoft Docs.

Some scaffolding options create no views, but JetBrains Rider highlights usages of the missing views, and you can create those views individually from the controller — place the caret at the highlighted View(); and press Alt+Enter and choose one of the options for creating a view:

JetBrains Rider: ASP.NET Scaffolding. Create missing Views
Last modified: 05 September 2023