Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolding into Blazor Server apps #17940

Merged
merged 11 commits into from
Jun 4, 2020
2 changes: 1 addition & 1 deletion aspnetcore/includes/scaffold-identity/hsts.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
`UseHsts` is recommended but not required. See [HTTP Strict Transport Security Protocol](xref:security/enforcing-ssl#http-strict-transport-security-protocol-hsts) for more information.
`UseHsts` is recommended but not required. For more information, see [HTTP Strict Transport Security Protocol](xref:security/enforcing-ssl#http-strict-transport-security-protocol-hsts).
34 changes: 15 additions & 19 deletions aspnetcore/includes/scaffold-identity/id-scaffold-dlg-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ Run the Identity scaffolder:
* 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. When an existing *\_Layout.cshtml* file is selected, it is **not** overwritten.

For example:
`~/Pages/Shared/_Layout.cshtml` for Razor Pages
`~/Views/Shared/_Layout.cshtml` for MVC projects
* Select your existing layout page so your layout file isn't overwritten with incorrect markup. When an existing *\_Layout.cshtml* file is selected, it is **not** overwritten. For example:
* `~/Pages/Shared/_Layout.cshtml` for Razor Pages or Blazor Server projects with existing Razor Pages infrastructure
* `~/Views/Shared/_Layout.cshtml` for MVC projects or Blazor Server projects with existing MVC infrastructure
* To use your existing data context, select at least one file to override. You must select at least one file to add your data context.
* Select your data context class.
* Select **Add**.
* To create a new user context and possibly create a custom user class for Identity:
* Select the **+** button to create a new **Data context class**.
* 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**.

Note: If you're creating a new user context, you don't have to select a file to override.
Expand All @@ -29,7 +27,7 @@ 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 (\*.csproj) file. Run the following command in the project directory:
Add required NuGet package references to the project file (*.csproj*). Run the following commands in the project directory:

```dotnetcli
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Expand All @@ -51,13 +49,13 @@ 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. Use the correct fully qualified name for your DB context:

```dotnetcli
dotnet aspnet-codegenerator identity -dc MyWeb.Data.ApplicationDbContext --files "Account.Register;Account.Login"
dotnet aspnet-codegenerator identity -dc MyApplication.Data.ApplicationDbContext --files "Account.Register;Account.Login"
```

PowerShell uses semicolon as a command separator. When using PowerShell, escape the semi-colons in the file list or put the file list in double quotes. For example:

```dotnetcli
dotnet aspnet-codegenerator identity -dc MyWeb.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
dotnet aspnet-codegenerator identity -dc MyApplication.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
```

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.
Expand All @@ -75,16 +73,14 @@ Run the Identity scaffolder:
* 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. When an existing *\_Layout.cshtml* file is selected, it is **not** overwritten.

For example:
`~/Pages/Shared/_Layout.cshtml` for Razor Pages
`~/Views/Shared/_Layout.cshtml` for MVC projects
* Select your existing layout page, or your layout file will be overwritten with incorrect markup. When an existing *\_Layout.cshtml* file is selected, it is **not** overwritten. For example:
* `~/Pages/Shared/_Layout.cshtml` for Razor Pages
* `~/Views/Shared/_Layout.cshtml` for MVC projects
* To use your existing data context, select at least one file to override. You must select at least one file to add your data context.
* Select your data context class.
* Select **Add**.
* To create a new user context and possibly create a custom user class for Identity:
* Select the **+** button to create a new **Data context class**.
* 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**.

Note: If you're creating a new user context, you don't have to select a file to override.
Expand All @@ -97,7 +93,7 @@ If you have not previously installed the ASP.NET Core scaffolder, install it now
dotnet tool install -g dotnet-aspnet-codegenerator
```

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:
Add a package reference to [Microsoft.VisualStudio.Web.CodeGeneration.Design](https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/) to the project file (*.csproj*). Run the following commands in the project directory:

```dotnetcli
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Expand All @@ -113,17 +109,17 @@ 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. Use the correct fully qualified name for your DB context:

```dotnetcli
dotnet aspnet-codegenerator identity -dc MyWeb.Data.ApplicationDbContext --files "Account.Register;Account.Login"
dotnet aspnet-codegenerator identity -dc MyApplication.Data.ApplicationDbContext --files "Account.Register;Account.Login"
```

PowerShell uses semicolon as a command separator. When using PowerShell, escape the semi-colons in the file list or put the file list in double quotes. For example:

```dotnetcli
dotnet aspnet-codegenerator identity -dc MyWeb.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
dotnet aspnet-codegenerator identity -dc MyApplication.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
```

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.

---

::: moniker-end
::: moniker-end
17 changes: 9 additions & 8 deletions aspnetcore/includes/scaffold-identity/id-scaffold-dlg.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ Run the Identity scaffolder:
# [Visual Studio](#tab/visual-studio)

* 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
`~/Pages/Shared/_Layout.cshtml` for Razor Pages
`~/Views/Shared/_Layout.cshtml` for MVC projects
* Select the **+** button to create a new **Data context class**.
* Select **ADD**.
* 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](#tab/netcore-cli)

Expand All @@ -19,7 +20,7 @@ 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 (\*.csproj) file. Run the following command in the project directory:
Add required NuGet package references to the project file (*.csproj*). Run the following commands in the project directory:

```dotnetcli
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Expand Down
Loading