(asp.net core mvc) How can I use identityUser in UI layer with product in entity layer

I’ve used Identity package in WebUI layer. I want to associate these users with the product that I keep in the entity layer.

Checkout below diagram image

(asp.net core mvc) How can I use identityUser in UI layer with product in entity layer

I cannot reference the Identity user class. How can I do that?

I am getting this below error.

(asp.net core mvc) How can I use identityUser in UI layer with product in entity layer

Thanks

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It seems that you are using the Traditional “N-Layer” architecture. Using this architecture, users make requests through the UI layer, which interacts only with the BLL (Business Logic Layer). The BLL, in turn, can call the DAL (Data Access Layer) for data access requests. The UI layer shouldn’t make any requests to the DAL directly, nor should it interact with persistence directly through other means. Likewise, the BLL should only interact with persistence by going through the DAL. In this way, each layer has its own well-known responsibility.

Normally, the DAL and BLL application are class library, when we use it, we could add the project reference (find the build .dll file).

I want to associate these users with the product that I keep in the
entity layer. I cannot reference the Identity user class. How can I do
that?

So, about this issue, you could try to put the Identity User class in the DAL layer and configure relationship with other model, then add reference in the BLL layer or the UI layer.

More detail information about Common web application architectures, check the following articles:

Common web application architectures

N-Tier Architecture in ASP.NET Core

N-Tier Architecture and Tips

Method 2

You could add a Data Access Layer for your Identity DbContext: Tutorial video

The Business layer can reference the Identity Data Access Layer. The BLL can take care of finding users and finding Products(I’m guess are stored in Adt.DataAccess layer). If you need to do processing of AspNetUsers table against Products table, you can always combine the results of querying both Data Access Layers in memory in the BLL.

(asp.net core mvc) How can I use identityUser in UI layer with product in entity layer


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x