安装后未创建hangfire数据库

问题描述 投票:1回答:1

我和Nuget一起安装了篝火。

PM> Install-Package Hangfire

然后使用以下行更新OWIN Startup类:

public void Configuration(IAppBuilder app)
{
    GlobalConfiguration.Configuration.UseSqlServerStorage("MySqlConnection");

    app.UseHangfireDashboard();
    app.UseHangfireServer();
}

我将web.config上的连接字符串名称命名为connectionString在UseSqlServerStorage中的名称。

web.config中:

<connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/CRMModelContext.csdl|res://*/CRMModelContext.ssdl|res://*/CRMModelContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=xxx;persist security info=True;user id=sa;password=123;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="MySqlConnection" connectionString="User ID=sa;Initial Catalog=xxx;Password=123;Integrated Security=False;Data Source=." />

SQL Server 2008 R2安装在系统上,但不包含hangfire的数据库。

最后,当我运行程序时,错误如下。

我的工作:

BackgroundJob.Enqueue<Receiver>(x=>x.EmailReceiving());
RecurringJob.AddOrUpdate<Receiver>(x => x.EmailReceiving(), Cron.MinuteInterval(15));

错误:

 JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API. 
hangfire
1个回答
0
投票

GlobalConfiguration.Configuration.UseSqlServerStorage("MySqlConnection");使用MySqlConnection作为连接字符串,而不是MySqlConnection的值!

您使用的是MsSql Server还是MySql Server?

试试:

GlobalConfiguration.Configuration.UseSqlServerStorage(ConfigurationManager.ConnectionStrings["MySqlConnection"].ConnectionString);
© www.soinside.com 2019 - 2024. All rights reserved.