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
If you get a scaffolding error, verify the Target Framework Moniker (TFM) matches the NuGet package version in the project file. For example, the following project file contains version 3.1 for .NET Core and the listed NuGet packages:
In the project folder, run the Identity scaffolder with the options you want. For example, to set up Identity with the default UI and the minimum number of files, run the following command. Use the correct fully qualified name for your DB context:
dotnet aspnet-codegenerator identity -dc MyApplication.Data.ApplicationDbContext --files "Account.Register;Account.Login"
If you run the Identity scaffolder without specifying the --files
flag or the --useDefaultUI
flag, all the available Identity UI pages will be created in your project.
Top comments (0)