Open Closed

I need help to pass IDbContextProvider to Appservice of module. This AppService will be called from POST Api #9205


User avatar
0
sghorakavi@cpat.com created
  • Create Module with Get and Post APIs. These APIs need to update DB table using IRepository
  • Include above Module in the main project
  • When IRepository is injected, Cannot access Module APpService from the API
  • Without IRepository can access AppService from API
  • What is missing ? Getting error in the api: Autofac.Core.DependencyResolutionException: An exception was thrown while activating LMSCommunicationController -> Cpat.Bridge.Module.LMSCommunicationAppService.  ---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'Cpat.Bridge.Module.LMSCommunicationAppService' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository2[Cpat.Bridge.Module.Data.LmsUserXref,System.Guid] lmsUserXrefRepository' of constructor 'Void .ctor(Volo.Abp.Domain.Repositories.IRepository2[Cpat.Bridge.Module.Data.LmsUserXref,System.Guid], Volo.Abp.Domain.Repositories.IRepository`2[Cpat.Bridge.Module.Data.LmsTenantXref,System.Guid], Volo.Saas.Host.ITenantAppService, Volo.Abp.Identity.IIdentityUserAppService, Volo.Abp.MultiTenancy.ICurrentTenant)'.

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

    hi

    Can you share the XXXEntityFrameworkCoreModule code of your module?

    Thanks.

  • User Avatar
    0
    sghorakavi@cpat.com created
    using Microsoft.Extensions.DependencyInjection;
    using Volo.Abp.EntityFrameworkCore;
    using Volo.Abp.Modularity;
    using Volo.Saas.EntityFrameworkCore;
    using Volo.Abp.AuditLogging.EntityFrameworkCore;
    using Volo.Abp.OpenIddict.EntityFrameworkCore;
    using Volo.Abp.EntityFrameworkCore.SqlServer;
    using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
    using Volo.Abp.SettingManagement.EntityFrameworkCore;
    using Volo.Abp.Identity.EntityFrameworkCore;
    using Volo.Abp.PermissionManagement.EntityFrameworkCore;
    using Volo.Abp.TextTemplateManagement.EntityFrameworkCore;
    using Volo.Abp.LanguageManagement.EntityFrameworkCore;
    using Volo.Abp.Gdpr;
    using Volo.Abp.BlobStoring.Database.EntityFrameworkCore;
    
    namespace Cpat.Bridge.Module.EntityFrameworkCore;
    
    [DependsOn(
        typeof(ModuleDomainModule),
        typeof(AbpEntityFrameworkCoreModule)
    )]
    [DependsOn(typeof(SaasEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpAuditLoggingEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpOpenIddictProEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpEntityFrameworkCoreSqlServerModule))]
        [DependsOn(typeof(AbpBackgroundJobsEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpSettingManagementEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpIdentityProEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpPermissionManagementEntityFrameworkCoreModule))]
        [DependsOn(typeof(TextTemplateManagementEntityFrameworkCoreModule))]
        [DependsOn(typeof(LanguageManagementEntityFrameworkCoreModule))]
        [DependsOn(typeof(AbpGdprEntityFrameworkCoreModule))]
        [DependsOn(typeof(BlobStoringDatabaseEntityFrameworkCoreModule))]
        public class ModuleEntityFrameworkCoreModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<ModuleDbContext>(options =>
            {
                options.AddDefaultRepositories(includeAllEntities: true);
                
                /* Add custom repositories here. Example:
                * options.AddRepository<Question, EfCoreQuestionRepository>();
                */
            });
            context.Services.AddAbpDbContext<TMS_MVCDbContext>(options =>
            {
                options.AddDefaultRepositories(includeAllEntities: true);
    
                /* Add custom repositories here. Example:
                * options.AddRepository<Question, EfCoreQuestionRepository>();
                */
            });
        }
    }
    

    TMS_MVCDbContext is our DBContext.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Thanks, ModuleEntityFrameworkCoreModule seems no problem.

    Can you share a project to reproduce?

    liming.ma@volosoft.com

  • User Avatar
    0
    sghorakavi@cpat.com created

    Sending you the module code``

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I didn't receive any email. Can you confirm?

    You can also share file by https://wetransfer.com/

    Thanks.

  • User Avatar
    0
    sghorakavi@cpat.com created

    Thank you @maliming we resolved it. Now we have different issue.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great

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 23, 2025, 10:47