Search code examples
abp-framework

How to save users data in a Tiered application (separated dbcontext for identity server and application/module)


I have a question regarding an application that I am developing, I try to implement a Kanban solution.

I have separated the IdentityServer (Users, Roles, etc), from the module/app that I am implementing. (Tiered)

I would like to know how I should do to have user data in the module/app. I mean, it should have the "duplicate" users table or from the module/app can refer to the context of the identityServer database...

I am a bit lost...

For trying to give an example.

IdentityDbContext { Users, Roles, etc }

ApplicationDbContext { Board, Columns, Tags, Cards, CardUser, ¿User? }

In CardUser I would like to have the users related to Card (an N-M relationship). But I don't know if I should create an entity/DbSet in the ApplicationDbContext or just save the UserId and then for each UserId query data to db or do call to api to the IdentityServer.

I think it's hard for me to explain myself, I'm sorry if it doesn't make sense, I appreciate any kind of help/comment.

Thank you very much.


Solution

  • As per best practices, aggregate root can be referenced by its id, but it is recommended not to reference it with the navigation property.

    We have implemented a similar case for EventHub. You can see how we implemented it from the links below.

    https://github.com/abpframework/eventhub/blob/e19c32731655df8c78d082a84cb336263c5f081a/src/EventHub.Domain/Events/Speaker.cs#L10

    https://github.com/abpframework/eventhub/blob/e19c32731655df8c78d082a84cb336263c5f081a/src/EventHub.Application/Events/EventAppService.cs#L366


    You can try to create an Event to better understand the requirements of EventHub.

    https://www.openeventhub.com/