hangfire - 如何在 ASP.NET CORE Web API 中配置 Hangfire 以使用 postgresql 作为存储数据库?
问题描述
我同事的开发人员,我目前正在asp.net Core和Hangfire中开发一个Web API来执行一些后台作业处理,但我打算使用Postgresql作为我的数据存储。但是我的 WEB API 未能自动创建数据库对象,以便我可以使用 Hangfire。我需要你的帮助,提前谢谢。
**An unhandled exception occurred while processing the request.**
PostgresException: 42P01: relation "hangfire.counter" does not exist
Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, bool async, DataRowLoadingMode dataRowLoadingMode, bool readingNotifications, bool isReadingPrependedMessage)
Npgsql.NpgsqlDataReader.NextResult(bool async, bool isConsuming, CancellationToken cancellationToken)
Npgsql.NpgsqlDataReader.NextResult()
Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, bool async, CancellationToken cancellationToken)
Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, bool async, CancellationToken cancellationToken)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior)
Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, bool wasClosed, CommandBehavior behavior) in SqlMapper.cs
Dapper.SqlMapper.QueryImpl<T>(IDbConnection cnn, CommandDefinition command, Type effectiveType)+MoveNext() in SqlMapper.cs
System.Collections.Generic.List<T>..ctor(IEnumerable<T> collection)
System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)
Dapper.SqlMapper.Query<T>(IDbConnection cnn, string sql, object param, IDbTransaction transaction, bool buffered, Nullable<int> commandTimeout, Nullable<CommandType> commandType) in SqlMapper.cs
Dapper.SqlMapper.Query(IDbConnection cnn, string sql, object param, IDbTransaction transaction, bool buffered, Nullable<int> commandTimeout, Nullable<CommandType> commandType) in SqlMapper.cs
Hangfire.PostgreSql.PostgreSqlMonitoringApi+<>c__DisplayClass28_0.<GetTimelineStats>b__0(IDbConnection connection)
Hangfire.PostgreSql.PostgreSqlStorage.UseConnection<T>(Func<IDbConnection, T> func)
Hangfire.PostgreSql.PostgreSqlMonitoringApi.GetTimelineStats(IDictionary<string, DateTime> keyMaps)
Hangfire.PostgreSql.PostgreSqlMonitoringApi.GetHourlyTimelineStats(string type)
Hangfire.PostgreSql.PostgreSqlMonitoringApi.HourlySucceededJobs()
Hangfire.Dashboard.Pages.HomePage.Execute()
Hangfire.Dashboard.RazorPage.TransformText(string body)
Hangfire.Dashboard.RazorPage.ToString()
Hangfire.Dashboard.RazorPageDispatcher.Dispatch(DashboardContext context)
Hangfire.Dashboard.AspNetCoreDashboardMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)`enter code here`
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
解决方案
推荐阅读
- java - 如何对我的所有集成测试文件执行 BeforeEach
- sass - scss 创建数组 1 到 100 而不乱写
- reactjs - 如何使用 React.memo 与 react-redux 连接并设置 propsAreEqual?
- python - 在python中逐页逐列附加多个excel文件
- elasticsearch - Jmeter对ElasticSearch的http请求中的编码不正确
- excel - 如何使用计时器触发器在 azure function App 中创建 excel 文件
- c++ - 构建 CXX 对象 CMakeFiles 错误:ProductCategory *result = 0;未在范围内声明(SaleItem 有 Product Category Pointer 作为成员)
- django - Django 定义加载的 url 和显示的 temolate
- wordpress - Nginx - 将 Wordpress 作为子域运行,另一个应用程序在主域上运行
- reactjs - React Native 如何实现这个模型?从照片中反应原生作物