Open Closed

The goal is to integrate a separate DDD module with the host application while utilizing a shared database contex #9685


User avatar
0
start created

Hi,

You’ll find a full description of my issue in the attached PDF document.

https://1drv.ms/f/c/3cfe06e6a74eb84d/Evbn_wl7ZsxNhDL5el3RCyQBi5VYVQZFDnG0sH827_HuUA?e=QDIox8

Kindly respond only via email and not on the public forum.

Thanks


4 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To integrate a separate DDD module with the host application while utilizing a shared database context in ABP Framework, you should implement the following approach:

    1. Implement Shared DbContext Interface
      Define a common interface that both the host application and the module can implement for the shared entities.
    public interface ISharedDbContext : IEfCoreDbContext
       {
           DbSet<YourEntity> YourEntities { get; set; }
           // Add other shared DbSets here
       }
    
    1. Module DbContext Implements Shared Interface
      In your module, have the module's DbContext implement the shared interface.
    public class ModuleDbContext : AbpDbContext<ModuleDbContext>, ISharedDbContext
       {
           public DbSet<YourEntity> YourEntities { get; set; }
           // Other module-specific DbSets
       }
    
    1. Host Application DbContext Implements Shared Interface
      In the host application, have the main DbContext also implement the shared interface and include the module's entities.
    public class HostDbContext : AbpDbContext<HostDbContext>, ISharedDbContext
       {
           public DbSet<YourEntity> YourEntities { get; set; }
           // Other host-specific DbSets
       }
    
    1. Register Repositories for Shared Entities
      In the host application, register the repository for the module's entities using the host application's DbContext.
    context.Services.AddAbpDbContext<HostDbContext>(options =>
       {
           options.AddDefaultRepositories(includeAllEntities: true);
           options.AddRepository<YourEntity, YourEntityRepository>();
       });
    
    1. Use the Host DbContext for Both Host and Module
      When running in the host application, ensure that the module uses the host application's DbContext for all operations. This allows both the host and the module to work with the same database context and tables.

    2. Dependency Injection
      Inject the repository or DbContext as needed in your application or module services.

    public class YourAppService : ApplicationService
       {
           private readonly IRepository<YourEntity, Guid> _yourEntityRepository;
    
           public YourAppService(IRepository<YourEntity, Guid> yourEntityRepository)
           {
               _yourEntityRepository = yourEntityRepository;
           }
    
           // Use _yourEntityRepository for CRUD operations
       }
    

    This approach ensures that both the host application and the module operate on the same database context and tables, maintaining consistency and enabling seamless integration.

    Sources:

    If you need to see a full working example, refer to the official documentation and community articles linked above.


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    start created

    Please provide a concrete and detailed response, not a generic bot-style reply.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The error is Cannot resolve parameter 'Gaming.FortniteApi._MyStructure.IFortniteItemCacheRepository cacheRepository

    Can you share your project source code instead of screenshots?

    liming.ma@volosoft.com
    Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The IFortniteItemCacheRepository doesn't have an implementation.

    See https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs#L16-L22

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37