I was working on a new ASP.NET web application. In this application, I was trying to use Onion Architecture. The application was also using ASP.NET Identity 2.0. Our goal was to create application that will easily replace(if required) the ASP.NET Identity system with any other Identity system or ASP.NET Identity Entity Framework store with any other Identity store without changing anything in our web application. We were able to create a web application without ASP.NET Identity and OWIN dependency using Onion architecture. I have created ASPNETIdentityWithOnion solution using Onion Architecture, because I thought it might be helpful for me and community in future. The web application in this solution contains Microsoft ASP.NET Identity Samples controllers(plus a ProductController) and views but without ASP.NET Identity and OWIN dependency. It might be helpful for users creating a new application using Onion and ASP.NET Identity. Existing applications can also take benefit from this solution. Here are some of benefits of using this solution,
- The web application uses latest ASP.NET MVC 5.1 framework which include user, role and account management(everything that included in Microsoft ASP.NET Identity Samples) but without ASP.NET Identity and OWIN dependency.
- Since there is no dependency on ASP.NET Identity and OWIN, unit testing and mocking of controller become very easy.
- The ASP.NET Identity implementation in the solution uses int as Id(identity column) as key instead of string.
- If you are looking to replace the Identity store in future without changing anything in the web application.
- You might want the ASP.NET Identity system might be replaced in future with different Identity system without changing anything in the web application.
- If you are creating a new web application with Onion architecture.
- The solution include a generic repository, generic unit of work and generic service with async and pagination support.
- The solution also include NLog which log all the EF queries.
- The web application will be only depend upon core project.
- and more...
Please try/see/use the solution and let me know if you have any suggestion.