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

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