Open Closed

Custom dbcontext and the order of execution #7819


User avatar
0
moinahmed created

I have multiple custom modules implemented in my project and they have their own dbcontext classes.I'm unsure about the order of execution in such cases. How the different dbcontexts gets called? What is the best practice out here? I also need to implement some filtering as described here in each dbcontext: https://abp.io/community/articles/switching-between-organization-units-i5tokpzt


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share your application's DbContext code?

    [ReplaceDbContext(typeof(IIdentityDbContext))]
    [ReplaceDbContext(typeof(ITenantManagementDbContext))]
    [ConnectionStringName("Default")]
    public class MyProjectNameDbContext :
        AbpDbContext<MyProjectNameDbContext>,
        IIdentityDbContext,
        ITenantManagementDbContext
        
     * Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
     * and replaced them for this DbContext. This allows you to perform JOIN
     * queries for the entities of these modules over the repositories easily. You
     * typically don't need that for other modules. But, if you need, you can
     * implement the DbContext interface of the needed module and use ReplaceDbContext
     * attribute just like IIdentityDbContext and ITenantManagementDbContext.
     *
     * More info: Replacing a DbContext of a module ensures that the related module
     * uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
    
Made with ❤️ on ABP v9.0.0-preview Updated on September 19, 2024, 10:13