AspNetCore.Docs/aspnetcore/includes/scaffold-identity/id-scaffold-dlg.md

2.2 KiB

no-loc
Home
Privacy
Kestrel
appsettings.json
ASP.NET Core Identity
cookie
Cookie
Blazor
Blazor Server
Blazor WebAssembly
Identity
Let's Encrypt
Razor
SignalR

Run the Identity scaffolder:

Visual Studio

  • From Solution Explorer, right-click on the project > Add > New Scaffolded Item.
  • From the left pane of the Add New Scaffolded Item dialog, select Identity > Add.
  • In the Add Identity dialog, select the options you want.
    • Select your existing layout page, or your layout file will be overwritten with incorrect markup:
      • ~/Pages/Shared/_Layout.cshtml for Razor Pages
      • ~/Views/Shared/_Layout.cshtml for MVC projects
      • Blazor Server apps created from the Blazor Server template (blazorserver) aren't configured for Razor Pages or MVC by default. Leave the layout page entry blank.
    • Select the + button to create a new Data context class. Accept the default value or specify a class (for example, MyApplication.Data.ApplicationDbContext).
  • Select Add.

.NET Core CLI

If you have not previously installed the ASP.NET Core scaffolder, install it now:

dotnet tool install -g dotnet-aspnet-codegenerator

Add required NuGet package references to the project file (.csproj). Run the following commands in the project directory:

dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
dotnet add package Microsoft.AspNetCore.Identity.UI
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools

Run the following command to list the Identity scaffolder options:

dotnet aspnet-codegenerator identity -h

[!INCLUDE]

In the project folder, run the Identity scaffolder with the options you want. For example, to setup identity with the default UI and the minimum number of files, run the following command:

dotnet aspnet-codegenerator identity --useDefaultUI