Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: ABP Modular Angular application (Module Entity Referencing in Main DbContext (Potential Anti-Pattern)) #22241

Open
ayshamougamadou opened this issue Feb 28, 2025 · 1 comment

Comments

@ayshamougamadou
Copy link

Hi,

I have a question regarding the usage of DbContext in both the host and modular applications within ABP.

In ABP modular applications, entities defined within a module are referenced in the module’s DbContext. However, it appears that the same entities also need to be referenced in the main application’s DbContext.

This approach seems to introduce tight coupling between the module and the main application. Ideally, a module should remain self-contained without requiring its entities to be referenced in the main application's DbContext.

Could you clarify why this is necessary? If this approach is intentional, are there best practices to mitigate the coupling while maintaining modularity?

this is the link to the article : https://abp.io/docs/latest/tutorials/modular-crm/part-03

Additionally, here are the respective DbContext implementations:

Module's DbContext:
Image

Main Application's DbContext:
Image

@realLiangshiwei
Copy link
Member

You don't need to add it to your main application's DbContext.

The benefit of doing this is that it allows for some join queries.

See https://abp.io/docs/latest/framework/data/entity-framework-core/migrations#entityframeworkcore-project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants