From the course: .NET Microservices for Azure Developers
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Adding the ClinicDbContext class - Azure Tutorial
From the course: .NET Microservices for Azure Developers
Adding the ClinicDbContext class
- [Instructor] Now let's implement ClinicDbContext class. So let's add the NuGet package for EntityFrameworkCore and the in-memory provider. So I'm going to add this one. Let's install it. And now we're ready to create a new folder, say DataAccess. And now let's add a new class, which is ClinicDbContext. And let's use the file scope namespace syntax. We have to inherit from DbContext, and we need to add this other constructor. I'm going to use the primary constructor syntax, DbContextOptions of type ClinicDbContext. And I'm going to pass this to the base constructor just like this. And now I'm ready to create the class that I'm going to use as the entity. In this case, I want to use a record. So let's type public record, and let's name it, say Consultation. And this is going to have an Id, and then the Patient Id, the PatientName, and the age, so, int PatientAge. Let's put this in this other line. And then DateTime StartTime. Okay, now let's wrap every parameter just like this. And…
Contents
-
-
-
-
-
-
-
(Locked)
Creating the Clinic microservice2m 44s
-
(Locked)
Adding the ClinicDbContext class3m 44s
-
(Locked)
Implementing the ManagementService class5m 41s
-
(Locked)
Implementing the ClinicApplicationService class6m 35s
-
(Locked)
Adding resilience traits to the microservice using Polly3m 20s
-
(Locked)
Creating the Container App for the Clinic microservice1m 2s
-
(Locked)
Creating the Dockerfile and modifying the workflow3m 17s
-
(Locked)
Adding environment variables to the Clinic microservice4m 41s
-
(Locked)
Challenge: Implementing a new endpoint and memory cache1m 30s
-
(Locked)
Solution: Implement a new endpoint and memory cache2m 41s
-
(Locked)
-