Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Updates for unit 2 to minimal apis.
Browse files Browse the repository at this point in the history
  • Loading branch information
jongalloway committed May 22, 2022
1 parent 903caf5 commit 24ea7d5
Show file tree
Hide file tree
Showing 2 changed files with 450 additions and 70 deletions.
15 changes: 10 additions & 5 deletions docs/1. Create BackEnd API project.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ Before you start, you need to add the required packages.
}
```
> **Note**
> We're using the `=>Set<Speaker>)()` on that last line to [deal with nullable warnings](https://docs.microsoft.com/ef/core/miscellaneous/nullable-reference-types#dbcontext-and-dbset), since we know that EF Core will be initializing this `DbSet`.
1. Add a connection string to the *appsettings.json* file for this database:
```json
Expand Down Expand Up @@ -224,11 +227,12 @@ You'll see a simple API that returns weather forecasts and is mapped to the HTTP
### Using Visual Studio
1. Right-click the Project and select *Add* / *New Scaffolded Item...*. Select "API with read/write endpoints, using Entity Framework" and click `Add`.
1. Create a new *Endpoints* directory in the *BackEnd* project.
1. Right-click the **Project** and select **Add** > **New Scaffolded Item...**. Select **API with read/write endpoints, using Entity Framework** and click **Add**.
1. In the dialog, select the `Speaker` model for the Model Class.
1. Click the `+` button to add a new endpoint named `SpeakerEndpoints`.
1. Select `ApplicationDbContext` for the "Data Context Class" and click the `Add` button.
1. Check the `Enable Open API` checkbox and click the `Add` button.
1. Click the **+** button to add a new endpoint named `SpeakerEndpoints`.
1. Select `ApplicationDbContext` for the "Data Context Class" and click the **Add** button.
1. Check the **Enable Open API** checkbox and click the **Add** button.
![Scaffold SpeakersController in Visual Studio](images/scaffold-speaker-endpoint.png)
### Using the cmd line
Expand All @@ -245,7 +249,8 @@ You'll see a simple API that returns weather forecasts and is mapped to the HTTP
dotnet tool update -g dotnet-aspnet-codegenerator
```
> Note: You may need to close and reopen the console window to be able to use this tool.
> **Note****
> You may need to close and reopen the console window to be able to use this tool.
1. Run the following command to view the help for the `minimalapi` scaffolding command:
Expand Down
Loading

0 comments on commit 24ea7d5

Please sign in to comment.