From the course: Expert Domain-Driven Design (DDD) Implementation in .NET

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Refactoring the DbContext for handling domain events

Refactoring the DbContext for handling domain events - .NET Tutorial

From the course: Expert Domain-Driven Design (DDD) Implementation in .NET

Refactoring the DbContext for handling domain events

- [Instructor] We're now working with entirely different data. So we need to refactor the DbContext and create a new data structure to store the domain events and their associated metadata. So here in the ClinicDbContext, we can actually remove the OnModeledCreating method, since it's no longer needed. And now, we need to create a new record. Let's name it ConsultationEventData. So, ConsultationEventData. And I want this to have an Id. And then, the AggregateId. The EventName is Data. And this is very important, AssemblyQualifiedName. So let's align those parameters, just like this. And now we're ready to change the Consultations property to use ConsultationEventData, just like this. In other words, the domain events will have this structure in the database after they're persisted. Speaking of which, we need to create a code for writing and reading data. We're going to do that in the next video.

Contents