我使用的是abp框架,在项目期间从EF Core SqlServer切换到EF Core PostgreSQL Provider后,我在运行DbMigrator或Host项目时遇到以下错误。有人能帮我吗?
问题出在一个框架适当的方法中。我尝试恢复包清理和重建解决方案,我还从";C: \Users[用户名].nuget\packages";,从远程转发中重新加载它们。
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:UsersERRAFIQIDocumentsReposumar-api-postgresqlumar-apisrcUMAR.DbMigratorDbMigratorHostedService.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:UsersERRAFIQIDocumentsReposumar-api-postgresqlumar-apisrcUMAR.DbMigratorProgram.cs:line 30
at UMAR.DbMigrator.Program.<Main>(String[] args)
你能检查一下吗:
在EntityFrameworkCore
项目中
- 在
UMARDbContextFactory
中,第20行:
var builder = new DbContextOptionsBuilder<UMARDbContext>()
.UseNpgSql(configuration.GetConnectionString("Default"));
- 在
UMAREntityFrameworkCoreModule
中
Configure<AbpDbContextOptions>(options =>
{
options.UseNpgSql();
});
HttpApi.Host
项目
- 在程序类中,添加:
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
之前:Log.Logger = new LoggerConfiguration()
注意:还要检查DbMigrator
和HttpApi.Host
项目中的所有应用程序设置文件配置