Starts in:
2 DAYS
0 HR
12 MIN
28 SEC
Starts in:
2 D
0 H
12 M
28 S

Activities of "Neozzz"

If you could check the code that'd be great. Taking remote would be easier for you as the infra is running and debugging may be easier. Let me know.

I had created a new class DatabaseMigrationEventHandlerBaseMongo for handling mongo db instead of DatabaseMigrationEventHandlerBase which uses ef core. It inherits from AbpMongoDbContext instead of AbpDbContext.

I think this is causing the issue.

after adding that only i added the DI code.

I added the following:

context.Services.AddSingleton(typeof(UnitOfWorkManager));
            context.Services.AddSingleton(typeof(UnitOfWorkMongoDbContextProvider<>));
            context.Services.AddSingleton(typeof(AbpMongoDbContextOptions));

The error:

 [ERR] An exception was thrown while activating ZW.MySvc.DbMigrations.MySvcDatabaseMigrationEventHandler.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating ZW.MySvc.DbMigrations.MySvcDatabaseMigrationEventHandler.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'ZW.MySvc.DbMigrations.MySvcDatabaseMigrationEventHandler' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.String databaseName' of constructor 'Void .ctor(Volo.Abp.MultiTenancy.ICurrentTenant, Volo.Abp.Uow.IUnitOfWorkManager, Volo.Abp.MultiTenancy.ITenantStore, Volo.Saas.Tenants.ITenantRepository, Volo.Abp.EventBus.Distributed.IDistributedEventBus, System.String, System.IServiceProvider)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
   at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
   at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)

I have done the above changes as you suggested. But I am getting the following error. I'd request you to take a look at the code.

2021-11-24 22:37:37.642 +04:00 [ERR] An exception was thrown while activating ZW.mySvc.DbMigrations.mySvcDatabaseMigrationEventHandler.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating ZW.mySvc.DbMigrations.mySvcDatabaseMigrationEventHandler.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'ZW.mySvc.DbMigrations.mySvcDatabaseMigrationEventHandler' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.String databaseName' of constructor 'Void .ctor(Volo.Abp.MultiTenancy.ICurrentTenant, Volo.Abp.Uow.IUnitOfWorkManager, Volo.Abp.MultiTenancy.ITenantStore, Volo.Saas.Tenants.ITenantRepository, Volo.Abp.EventBus.Distributed.IDistributedEventBus, System.String, System.IServiceProvider)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
   at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
   at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   --- End of inner exception stack trace ---

Please let me know how to proceed.

[DependsOn(
        typeof(PJNameSharedHostingMicroservicesModule),
        typeof(MySvcApplicationModule),
        typeof(MySvcHttpApiModule),
        typeof(MySvcMongoDbModule)
        )]
    public class MySvcHttpApiHostModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {           
            context.Services.AddSingleton(typeof(UnitOfWorkManager));
            Configure<AbpUnitOfWorkDefaultOptions>(options =>
            {
                options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
            });
            JwtBearerConfigurationHelper.Configure(context, "MySvc");
            SwaggerConfigurationHelper.Configure(context, "MySvc API");
        }

        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var app = context.GetApplicationBuilder();
            var env = context.GetEnvironment();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCorrelationId();
            app.UseAbpRequestLocalization();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAbpClaimsMap();
            app.UseMultiTenancy();
            app.UseAuthorization();
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "MySvc API");
            });
            app.UseAbpSerilogEnrichers();
            app.UseAuditing();
            app.UseUnitOfWork();
            app.UseConfiguredEndpoints();
        }

        public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
        {
            using (var scope = context.ServiceProvider.CreateScope())
            {
                AsyncHelper.RunSync(
                    () => scope.ServiceProvider
                        .GetRequiredService<MySvcDatabaseMigrationChecker>()
                        .CheckAsync()
                );
            }
        }
    }

    [Dependency(ReplaceServices = true)]
    public class MyUnitOfWorkManager : IUnitOfWorkManager, ISingletonDependency
    {
        private readonly UnitOfWorkManager _innerUnitOfWorkManager;

        public MyUnitOfWorkManager(UnitOfWorkManager innerUnitOfWorkManager)
        {
            _innerUnitOfWorkManager = innerUnitOfWorkManager;
        }

        public IUnitOfWork Begin(AbpUnitOfWorkOptions options, bool requiresNew = false)
        {
            options.IsTransactional = false;
            return _innerUnitOfWorkManager.Begin(options, requiresNew);
        }

        public IUnitOfWork Reserve(string reservationName, bool requiresNew = false)
        {
            return _innerUnitOfWorkManager.Reserve(reservationName, requiresNew);
        }

        public void BeginReserved(string reservationName, AbpUnitOfWorkOptions options)
        {
            options.IsTransactional = false;
            _innerUnitOfWorkManager.BeginReserved(reservationName, options);
        }

        public bool TryBeginReserved(string reservationName, AbpUnitOfWorkOptions options)
        {
            options.IsTransactional = false;
            return _innerUnitOfWorkManager.TryBeginReserved(reservationName, options);
        }

        public IUnitOfWork Current => _innerUnitOfWorkManager.Current;
    }
}

we have a microservice-pro solution that uses efcore. i need to add a microservice service inside this solution. but this has to use mongo for storing its entities but at the same time has to make use of the efcore for saas, admin etc.

i have tried something, but while migrating we've to divide the concerns to both mongo and efcore. guess this is where am having the issue.

please lemme know how to proceed.

hi maliming,

this was my question: https://support.abp.io/QA/Questions/1269/using-MongoDB-in-microservice-service-inside-microservice-solution-which-uses-efcore#answer-3c384c74-c57f-d8c8-f71a-3a005a05e232

hi,

please update.

hi liang, kind reminder.

Showing 1 to 10 of 128 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06