2018-05-17 07:12:09 +08:00
Run the Identity scaffolder:
2018-06-05 13:22:57 +08:00
# [Visual Studio](#tab/visual-studio)
2018-05-17 07:12:09 +08:00
* From **Solution Explorer** , right-click on the project > **Add** > **New Scaffolded Item** .
* From the left pane of the **Add Scaffold** 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. For example
2018-06-05 13:22:57 +08:00
`~/Pages/Shared/_Layout.cshtml` for Razor Pages
`~/Views/Shared/_Layout.cshtml` for MVC projects
2018-05-17 07:12:09 +08:00
* Select the ** +** button to create a new **Data context class** .
* Select **ADD** .
# [.NET Core CLI](#tab/netcore-cli)
2018-08-16 11:30:29 +08:00
If you have not previously installed the ASP.NET Core scaffolder, install it now:
2018-05-17 07:12:09 +08:00
2019-09-18 05:01:04 +08:00
```dotnetcli
2018-05-31 05:32:45 +08:00
dotnet tool install -g dotnet-aspnet-codegenerator
2018-05-17 07:12:09 +08:00
```
Add a package reference to [Microsoft.VisualStudio.Web.CodeGeneration.Design ](https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/ ) to the project (\*.csproj) file. Run the following command in the project directory:
2019-09-18 05:01:04 +08:00
```dotnetcli
2018-06-05 13:22:57 +08:00
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
2018-05-17 07:12:09 +08:00
dotnet restore
```
Run the following command to list the Identity scaffolder options:
2019-09-18 05:01:04 +08:00
```dotnetcli
2018-05-17 07:12:09 +08:00
dotnet aspnet-codegenerator identity -h
```
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:
2019-09-18 05:01:04 +08:00
```dotnetcli
2018-05-17 07:12:09 +08:00
dotnet aspnet-codegenerator identity --useDefaultUI
```
2018-06-05 13:22:57 +08:00
2019-03-21 13:13:02 +08:00
---