/multiple-databases-aspnetcore

This repo contains the source code for the "Using Multiple Databases in ASP.NET Core via Entity Framework Core" article on Code Maze

Primary LanguageC#MIT LicenseMIT

Using Multiple Databases in ASP.NET Core via Entity Framework Core

https://code-maze.com/aspnetcore-multiple-databases-efcore

In this article, we are going to learn how to add multiple databases in the ASP.NET Core project using Entity Framework Core.

We are going to show you how our repository pattern implementation helps us in the process by using abstractions that will hide all the implementation details from the presentation layer. 

Since we already have the repository pattern explained in our ASP.NET Core Repository Pattern article, we strongly suggest reading it first to learn more about the repository pattern implementation in ASP.NET Core Web API. We will modify the source code from that project and show you the benefits of the implementation of that pattern when adding multiple databases in an ASP.NET Core project. 

We are going to divide this article into the following sections:

  • Using Multiple Databases to Support Migrations
  • Registering Contexts for Multiple Databases in ASP.NET Core
  • Injecting Multiple Databases in the Repository Pattern
  • Testing Data Fetching From Multiple Databases in ASP.NET Core
  • Conclusion