As far as I know, the DBContext or underlying persistance technology should be only contained inside the Data layer.
Also, it feels very wrong to me to have identity package inside the user interface layer. The identity should be the responsibility of a centralized business layer, which in case should be usable by other parts of the application (e.g. wpf, forms, web-api projects etc), and not just asp.net front-end.
If I separate the identity to another layer, this partially solves the problem, but this time, I have to specify the DBContext inside the Startup.cs file for front-end, which should only reference Business Layer and work with View Models or DTO's.
The business layer should provide the authorization/authentication services, and attributes for decorating relative methods for permissions.
Anything with the name "ASP.NET" should be contained inside the user interface layer.
Also, the dependency injection framework should also be partially configurable across layers of the application, which should permit specifying required instances of specific classes inside that layer.
I'm extremely confused about the choice of architecture in .NET Core.
Please guide me to the right way of creating the right architecture.
Thank you.
SupportsUserRole
onUsermanager
to find out if it implementsIUserRoleStore
, thus exposing the inner workings ofUsermanager
. – David Arno Oct 11 '19 at 9:58Startup.cs
is not "the front end". It's the start point of our entire application and it, with the help of an IoC container you may choose to use, is the only place where the concreteDBContext
should be decided upon and supplied to the business layer for example.It's unfortunate that the "main" of a ASP.NET Core app has to be located alongside the front end, but that doesn't make it part of the front end. – David Arno Oct 11 '19 at 9:59Startup.cs
. That way, you avoid needing a direct EF reference in your top-level project. You're right that the dependency registration needs to originate from there, but that's not exactly the same as needing to handle the exact dependency types there. – Flater Oct 11 '19 at 10:53