Business entities mutation and integration events: why are there multiple DbContexts?
marconato7 opened this issue · comments
Hello! How are you?
Say we are talking about the Catalog microservice.
I am having a hard time wrapping my head around the fact that there are two DbContexts: IntegrationEventLogContext and CatalogContext.
Why is that? 🤔
Thanks.
HI @kriubi, thanks for sharing your query here. The two DBContexts are used for different databases. One for IntegrationEventLogEntry and another for catalog data like Item, brand, and type. I hope it helps.
I am closing this issue, however, feel free to continue the conversation in case of further queries
Thanks for the reply, @erjain.
I don't think you are right, tho.
IntegrationEventLogContext
was deliberately made as a "building block" (shared code between microservices), but I still don't get it.
It feels like the decision to split entities between two contexts was made just to showcase this EF Core feature (as seen in CatalogIntegrationEventService.cs
): https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
Is there another reason why? Am I missing something?
Thanks again.
Also, will you reopen this issue? I'd like to continue the conversation 😁