I decided it was time for me to try cool things like the Onion architecture of the Repository + UnitOfWork, but I liked ASP.NET Identity quite a bit, which I would like to combine with such an application architecture. I didn’t like the examples that were found on the net. For example, http://metanit.com/sharp/mvc5/23.10.php the layer architecture is completely broken here, namely:
-in BLL layer is connected EntityFramework + Identity.EntityFramework -in DAL layer there is a bunch of business logic in the form of ApplicationRoleManager and ApplicationUserManager
etc...
Therefore, it was decided to make your bike. For a start, I took as an example a project that is generated when creating ASP.NET MVC with Identity already enabled and decided to repeat its functionality, while being divided into 3 layers. Here's what happened: https://github.com/dmitrievMV/OnionArchitectureWithASPNETIdentity
In DAL:
- Entities.
- EF context
- Repository + UnitOfWork
- UserStore
All implementations in the assembly are closed, except for UnitOfWork and UserStore. UserStore accepts UOW constructor and works with repositories. Only interfaces look outside. The database structure completely repeats the example from the small ones, except that the main keys are int.
In BLL: -ApplicationUserManager
In WEB -ApplicationSignInManager
Actually, please help, spend a little time, just inspect the code. Answer a couple of questions:
- Did I implement the Repository + UnitOfWork correctly?
- Is Dispose implemented correctly?
- In what layer do you think ApplicationSignInManager should be, because it uses OWIN and works with ApplicationUserManager
- Due to the fact that no layer other than DAL knows about the database and ORM, I decided to make connectionString in a constant, is this a normal approach?
- Does it make sense to bring entities into a separate project and separate them from annotations for the database?
- In the example in owin, the context puts the ef context like this: app.CreatePerOwinContext (ApplicationDbContext.Create); How much is this justified and is it worth doing so?
- In the UserStore implementation for EF, it is very strange to behave with dispose and I have a feeling that some data is permanently stored in memory, is it?
- How justified is such a bike?