I'm trying to achieve good separation and architecture between ASP.NET Core Identity and entities in my domain model.
I'm using an Onion architecture in a web application built with ASP.NET Core.
In the core project, Domain
, I have domain models, and one of them being a Member
entity.
Then in another project, Infrastructure
, I have the built in ASP.NET Core Identity setup which contains an ApplicationUser
class that inherits from IdentityUser
.
public class ApplicationUser : IdentityUser
{
}
The idea of having the identity user and member entity separated is good. However, I want to relate them but using Entity Framework Core this seems to be a challenge. I cannot get around this without adding navigation properties in my domain models, which I'd like to avoid.
I was hoping I could do it entirely using Fluent API without having to add properties but that does not seem to be the case.
Any recommendations on how to approach this? Considering the above how could I create a relationship between the identity user and a domain entity without adding dependencies from the core project?
My question is somewhat a duplicate or related to some of these posts here e.g.
- Decoupling ASP.NET Identity from the Core Domain Models - Onion Architecture
- Onion Architecture Identity Framework
- Add relationship to .NET Identity ApplicationUser for entity in Data layer
and some other posts as well. However, the answers to these questions seems to be workarounds. Maybe that is the only way?
I'm using ASP.NET Core 3.1 and Entity Framework 3.1. for this project.