Hi,
We have 2 databases with same structure (same entity, one of the databases is snapshot of the other live database) Some of the service on the system will read from the snapshot database, and most of the services will manage the live database.
What is the best option to implement this? and how we can force the repository to ready from the snapshot database?
Regards
1 Answer(s)
-
0
Hi @samara081
As a first option, you can create your own implementation of https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Domain/Uow/IConnectionStringResolver.cs, inject IHttpContextAccessor in it and decide according to used http method. But, this approach will use same connection string for each request. So, you can't use different databases in a single request.
Other option would be implemneting your own version of https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/IDbContextResolver.cs similar to https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/DefaultDbContextResolver.cs