Hangfire MySqlStorage - HttpConfiguration 不包含 'UseStorage' 的定义

Hangfire MySqlStorage - HttpConfiguration does not contain a definition for 'UseStorage'

我正在尝试在 Web API 应用程序中使用 Hangfire MySqlStorage 和 mysql 数据库。我安装了 NuGet 包 "Hangfire.MySqlStorage" 版本 1.0.3。当我配置 Hangfire 时出现以下错误,

HttpConfiguration does not contain a definition for 'UseStorage' and no extension method 'UseStorage' accepting a first argument of type 'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?)

我好像遗漏了这里的参考资料。想不通。

看来您在错误的对象上调用了方法。

根据文档应该是:

GlobalConfiguration.Configuration.UseStorage(
    new MySqlStorage(connectionString));

其中 GlobalConfiguration 实际上是来自 Hangfire.Core 库的 Hangfire.GlobalConfiguration