You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. AddareferencetotheNuGetpackage `Microsoft.EntityFrameworkCore.Tools` version `3.0.0`.
100
-
>**Ifyou're not using Visual Studio** install the package from the command line with `dotnet add package Microsoft.EntityFrameworkCore.Tools --version 3.0.0`
105
+
1. AddareferencetotheNuGetpackage `Microsoft.EntityFrameworkCore.Tools` version `3.1.3`.
106
+
>**Ifyou're not using Visual Studio** install the package from the command line in the `BackEnd` folder with `dotnet add package Microsoft.EntityFrameworkCore.Tools --version 3.1.3`
101
107
102
108
### Visual Studio: Package Manager Console
103
109
@@ -111,9 +117,9 @@
111
117
112
118
### Command line
113
119
114
-
1. Install the EntityFramework global tool `dotnet-ef` using the following command:
120
+
1. Install the EntityFramework global tool `dotnet-ef` using the following command in the `BackEnd` folder:
115
121
```console
116
-
dotnet tool install -g dotnet-ef --version 3.0.0
122
+
dotnet tool install -g dotnet-ef --version 3.1.3
117
123
```
118
124
119
125
1. Open a command prompt and navigate to the project directory. (The directory containing the `Startup.cs` file).
@@ -147,12 +153,12 @@ First, open the `Controllers` folder and take a quick look at the `WeatherForeca
147
153
### Using the cmd line
148
154
1. Install the "Microsoft.VisualStudio.Web.CodeGeneration.Design" package
> Note: You will need to close and reopen the console window to be able to use this tool.
@@ -171,8 +177,8 @@ In this section, we'll be adding documentation to our API using the Swashbuckle
171
177
172
178
Additional information on using Swashbuckle in ASP.NET Core is available in this tutorial: [ASP.NET Web API Help Pages using Swagger](https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger)
173
179
174
-
1. Add a reference to the NuGet package `Swashbuckle.AspNetCore` version `5.0.0-rc4`.
175
-
> This can be done from the command line using `dotnet add package Swashbuckle.AspNetCore --version 5.0.0-rc4`
180
+
1. Add a reference to the NuGet package `Swashbuckle.AspNetCore` version `5.3.0`.
181
+
> This can be done from the command line using `dotnet add package Swashbuckle.AspNetCore --version 5.3.0`
176
182
177
183
1. Add the Swashbuckle services in your `ConfigureServices` method:
178
184
```csharp
@@ -182,6 +188,14 @@ Additional information on using Swashbuckle in ASP.NET Core is available in this
182
188
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Conference Planner API", Version = "v1" })
183
189
);
184
190
```
191
+
192
+
1. Ensure your Startup.cs file contains the following 'using' statements:
193
+
```csharp
194
+
using Microsoft.OpenApi.Models;
195
+
using System.Threading.Tasks;
196
+
```
197
+
198
+
185
199
1. Configure Swashbuckle by adding the following lines just before `UseRouting` in the `Configure` method in `Startup.cs`:
186
200
```csharp
187
201
app.UseSwagger();
@@ -190,17 +204,18 @@ Additional information on using Swashbuckle in ASP.NET Core is available in this
190
204
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Conference Planner API v1")
191
205
);
192
206
```
193
-
> ***Note:* Due to how the middleware and pipeline are structured, you'll want to place this before the `app.UseEndpoints()` statement.**
194
-
1. Add a redirect to the end of the pipeline that redirects to the swagger end point.
207
+
1. Add a MapGet to the beginning of the `UseEndpoints` statement in the pipeline that redirects requests from the root of our application to the swagger end point.
195
208
```csharp
196
-
app.Run(context =>
197
-
{
198
-
context.Response.Redirect("/swagger");
199
-
return Task.CompletedTask;
200
-
});
201
-
```
202
-
203
-
> ***Note:* You'll need to place this after the `app.UseMvc()` statement.**
209
+
app.UseEndpoints(endpoints =>
210
+
{
211
+
endpoints.MapGet("/", context => {
212
+
context.Response.Redirect("/swagger/");
213
+
return Task.CompletedTask;
214
+
});
215
+
endpoints.MapControllers();
216
+
});
217
+
```
218
+
204
219
1. Run the application (F5 in Visual Studio or `dotnet run` from console).
205
220
1. Browse to the Swagger UI at `http://localhost:<random_port>/swagger`.
206
221

@@ -210,9 +225,9 @@ Additional information on using Swashbuckle in ASP.NET Core is available in this
1. When you click the *Try it out!* button, you should see a success response from the server. Now, clicking the *GET* button above should show your newly added speaker.
Copy file name to clipboardExpand all lines: docs/2. Build out BackEnd and Refactor.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -31,8 +31,8 @@ In this session, we'll add the rest of our models and controllers that expose th
31
31
## Refactoring the Speaker model into the ConferenceDTO project
32
32
1. Copy the `Speaker.cs` class from the *BackEnd* application into the root of the new ConferenceDTO project, and change the namespace to `ConferenceDTO`.
33
33
1. The data annotations references should be broken at this point, to resovle it, we need to add a nuget the missing NuGet package into the `ConferenceDTO` project.
34
-
1. Add a reference to the NuGet package `System.ComponentModel.Annotations` version `4.6.0`.
35
-
> This can be done from the command line using `dotnet add package System.ComponentModel.Annotations --version 4.6.0`
34
+
1. Add a reference to the NuGet package `System.ComponentModel.Annotations` version `4.7.0`.
35
+
> This can be done from the command line using `dotnet add package System.ComponentModel.Annotations --version 4.7.0`
36
36
37
37
1. When the package restore completes, you should see that your data annotations are now resolved.
38
38
1. Go back to the *BackEnd* application and modify the code in `Speaker.cs` as shown:
Copy file name to clipboardExpand all lines: docs/6. Production Readiness and Deployment.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Production Readiness and Deployment
2
2
3
3
## Adding EF Healthchecks to the BackEnd
4
-
1. Add a reference to the NuGet package `Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` version `3.0.0`.
5
-
> This can be done from the command line using `dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore --version 3.0.0`
4
+
1. Add a reference to the NuGet package `Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` version `3.1.3`.
5
+
> This can be done from the command line using `dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore --version 3.1.3`
6
6
1. Add a DbContext health check in `Startup.cs` by adding the following code to `ConfigureServices`:
7
7
```csharp
8
8
services.AddHealthChecks()
@@ -13,7 +13,7 @@
13
13
14
14
## Adding EF Healthchecks to the FrontEnd
15
15
1. Add a reference to the NuGet package `Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` version `3.0.0`.
16
-
> This can be done from the command line using `dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore --version 3.0.0`
16
+
> This can be done from the command line using `dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore --version 3.1.3`
17
17
18
18
> Note: The `FrontEnd` and `BackEnd` projects have different versions of this package because they reference different versions of EntityFrameworkCore.
19
19
1. Add a DbContext health check in `Startup.cs` by adding the following code to `ConfigureServices`:
Copy file name to clipboardExpand all lines: save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Migrations/20191230162921_Initial.Designer.cs
Copy file name to clipboardExpand all lines: save-points/1-Create-API-and-EF-Model/ConferencePlanner/BackEnd/Migrations/ApplicationDbContextModelSnapshot.cs
0 commit comments