Extend ApplicationUser with Domain entities relationship
See original GitHub issueHello,
I was wondering how one could extend the ApplicationUser
the cleanest way possible if I need a one-to-many relationship between ApplicationUser
and one entity from my Domain project.
Should I just move ApplicationUser
to my Domain model? Right now, I cannot do it since my domain model has no idea about ApplicationUser
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Add relationship to .NET Identity ApplicationUser for entity ...
I dont know how to be able to place the AppUser class in my data layer so that IdentityConfig can be able to...
Read more >Extending IdentityUser With Custom Properties in ASP.NET
In this article, we'll learn all possibilities of extending IdentityUser with custom properties and changing the primary key type.
Read more >Part 2: Creating the Domain Models
This tutorial shows how to create domain models by using the code-first approach to Entity Framework.
Read more >Identity model customization in ASP.NET Core
This article describes how to customize the underlying Entity Framework Core data model for ASP.NET Core Identity.
Read more >Domain-Driven Design in ASP.NET Core applications
A library of basic concepts of Domain-Driven Design pattern and provide a practical example of how to apply DDD in a typical ....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Then you already have multiple options listed above to accomplish that.
The easiest and quickest way is to simply have
Entity
inherit fromAuditableEntity
. This way theCreatedBy
property will be populated with the current user’s ID automatically whenEntity
is added to the Db.When retrieving
Entity
from the Db, just injectICurrentUserService
into your Get Entity handler and select whereCreatedBy == _currentUserService.UserId
.E.e.
In any case, your issue is a software design issue and not an issue related to this project. The above comments more than cover the issue you described. If you need further help, I suggest you post a question on StackOverflow (where questions like this belong).
Good luck.
Thanks for your help @GFoley83. 😀