Decoupling ASP.NET Identity from the Core Domain Models - Onion Architecture

后端 未结 3 1789
清歌不尽
清歌不尽 2021-02-01 10:03

I am using this sample project (https://github.com/imranbaloch/ASPNETIdentityWithOnion) as my application architecture, in this sample the core is completly decoplied from the i

3条回答
  •  死守一世寂寞
    2021-02-01 10:23

    Okay I have solved this by doing the following:

    1. Include a dependency in your Core to Microsoft.AspNet.Identity.Core
    2. Implement IUser interface on the AppUser (this interface come from Microsoft.AspNet.Identity.Core).
    3. Implement IRole interface on the ApplicationRole.
    4. Completely get rid of the IdentityDbContext and inherit only from DbContext.
    5. Implement your own version of IUserStore* providing your AppUser
    6. Implement your own version of IRoleStore providing your ApplicationRole.

    I know that making a dependency on the Microsoft.AspNet.Identity.Core sounds Odd, but we only need the interface IUser which is basically considered as Core Domain Model for your application too.

    The Ultimate Idea here is to GET RID OF THE Microsoft.AspNet.Identity.EntityFramework completely.

    Interested devs can +1 this, so I can upload a full working sample on GitHub.

提交回复
热议问题