-
Close Visual Studio.
-
Open a command prompt (powershell) and change directories to the project location.
-
Make sure the aspnet-codegenerator tool is installed on your machine by executing this command:
dotnet tool install -g dotnet-aspnet-codegenerator
- Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project if it does not already exist in your project.
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
- Add Microsoft.EntityFrameworkCore.Design package to the project if it does not already exist in your project.
Install-Package Microsoft.EntityFrameworkCore.Design
- Run the following command where YourDbContext.Namespace.ApplicationDbContext is the namespace to your DbContext:
dotnet aspnet-codegenerator identity -dc YourDbContext.Namespace.ApplicationDbContext
dotnet aspnet-codegenerator also has the ability to scaffold only specific files versus all the Identity files if you don’t need the full set by passing in the -files parameter followed by the files you want to create.
dotnet aspnet-codegenerator identity -dc ourDbContext.Namespace.ApplicationDbContext –files “Account.Register;Account.Login;Account.Logout”