I currently have two ASP.NET Core projects that share some business logic classes, as well as DbContext
. They are injected as dependencies in ConfigureServices
, just like what Microsoft Docs usually show us.
However when it comes to deployment, my client suggests to separate database access (i.e. whatever business logic that requires database connection) to a different server and serve as web api.
I found that this idea is rarely mentioned from the Internet but somehow makes such sense to me - this makes sure even if someone hacks into the web server, they do not have direct database access and cause damage or leak to data.
Can anyone tell me if it is a good practice or it is actually uneccessary?
DbContext
into the project, but I am then told to wrap those things as a web api (3rd project), and whenever the frontend needs data, it fetches from web api rather than accessingDbContext
directly.