Abp framework : An error occurred during the initialize, after switching from EF Core SqlServer to EF Core PostgreSQL Provider

1.1k Views Asked by At

I'm using abp framework and after switching from EF Core SqlServer to EF Core PostgreSQL Provider during the project, I get the following error when I run the DbMigrator or Host projects. Can someone help me with this ?

The problem is in one of the framework proper methods. I tried restoring packages cleaning and rebuild the solution, I also deleted all local packages from "C:\Users[Username].nuget\packages", to reload them from remote repos.

Unhandled exception. Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.BackgroundJobs.AbpBackgroundJobsModule, Volo.Abp.BackgroundJobs, Version=5.3.2.0, Culture=neutral, PublicKeyToken=null: Method not found: 'System.Threading.Tasks.Task`1<Volo.Abp.ApplicationInitializationContext> Volo.Abp.BackgroundWorkers.BackgroundWorkersApplicationInitializationContextExtensions.AddBackgroundWorkerAsync(Volo.Abp.ApplicationInitializationContext)'.. See the inner exception for details.
 ---> System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<Volo.Abp.ApplicationInitializationContext> Volo.Abp.BackgroundWorkers.BackgroundWorkersApplicationInitializationContextExtensions.AddBackgroundWorkerAsync(Volo.Abp.ApplicationInitializationContext)'.
   at Volo.Abp.BackgroundJobs.AbpBackgroundJobsModule.OnApplicationInitializationAsync(ApplicationInitializationContext context)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Volo.Abp.BackgroundJobs.AbpBackgroundJobsModule.OnApplicationInitializationAsync(ApplicationInitializationContext context)
   at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.InitializeAsync(ApplicationInitializationContext context, IAbpModule module)
   at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context)
   --- End of inner exception stack trace ---
   at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context)
   at Volo.Abp.AbpApplicationBase.InitializeModulesAsync()
   at Volo.Abp.AbpApplicationWithInternalServiceProvider.InitializeAsync()
   at UMAR.DbMigrator.DbMigratorHostedService.StartAsync(CancellationToken cancellationToken) in C:\Users\ERRAFIQI\Documents\Repos\umar-api-postgresql\umar-api\src\UMAR.DbMigrator\DbMigratorHostedService.cs:line 32
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at UMAR.DbMigrator.Program.Main(String[] args) in C:\Users\ERRAFIQI\Documents\Repos\umar-api-postgresql\umar-api\src\UMAR.DbMigrator\Program.cs:line 30
   at UMAR.DbMigrator.Program.<Main>(String[] args)
1

There are 1 best solutions below

2
On

Can you check this:

In EntityFrameworkCore project

  • In UMARDbContextFactory, line 20:
    var builder = new DbContextOptionsBuilder<UMARDbContext>()
            .UseNpgSql(configuration.GetConnectionString("Default"));
  • In UMAREntityFrameworkCoreModule

        Configure<AbpDbContextOptions>(options =>
        {
            options.UseNpgSql();
        });

In HttpApi.Host project

  • In Program class, add:
    AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);

Before: Log.Logger = new LoggerConfiguration()

Note: Check also all appsettings file configuration, in DbMigrator and HttpApi.Host projects