I've started working on an existing ASP.NET Core project that uses the Identity framework. The application uses a single database. For some reason the application uses two separate database contexts - one derived from IdentityDbContext
which of course is used for managing User/Auth and the other derived from DbContext
which is used for anything other than User-related business.
I've seen previously applications using two separate database contexts, but every time they were using a separate database through the IdentityDbContext
. Maybe the previous developer(s) were trying to achieve something not clear to me.
So, what could be some possible advantages, which I might be missing, in my scenario of using two separate contexts while the application have a single database? Thanks.
Edit:
My understanding is, since I have a single database I could easily use only the IdentityDbContext
and it would serve every purpose which currently two separate contexts combined are serving. The application has various business entities (let's say Employee, Customer, Supplier, etc) which are not User
of the application, but can be made one at some future point by registration with respective level of role-based privileges. In such a scenario, using only the IdentityDbContext
gives me the advantage of creating one-to-one relationship with the AspNetUsers
table, which I cannot implement now simply because of the separate contexts.
Edit
. Do you then recommend not having such relationships? – Pontificals