When i`m use :
```
RecurringJob.AddOrUpdate
job => job.Run(JobCancellationToken.Null) ,
Cron.MinuteInterval(2),TimeZoneInfo.Local);
or another method from this class,
i get error:
> Invalid object name 'HangFire.Hash'
In my startupclass i have:
In configureService:
services.AddScoped
services.AddHangfire((config) => {
var options = new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = false,
QueuePollInterval = TimeSpan.FromHours(10)
};
config.UseSqlServerStorage("Server=(localdb)\mssqllocaldb;Database=CostsAnalyseDB;Trusted_Connection=True;MultipleActiveResultSets=true", options);
});
In Configure:
app.UseHangfireServer(new BackgroundJobServerOptions { WorkerCount = 1 });
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 0 });
app.UseHangfireDashboard();
ScheduleDriver.ScheduleReccuringJob();
ScheduleDriver contains :
RecurringJob.AddOrUpdate
job => job.Run(JobCancellationToken.Null) ,
Cron.MinuteInterval(2),TimeZoneInfo.Local);
In TaskDrive:
public class TaskDriver : ITask
{
private readonly ILogger
private readonly ApplicationContext _context;
public TaskDriver( ApplicationContext context)
{
_context = context;
}
public async Task RunAtTimeOf(DateTime now)
{
//_logger.LogInformation("Task from schedule start.");
//_logger.LogInformation("Task have been finished.");
}
public async Task Run(IJobCancellationToken token)
{
token.ThrowIfCancellationRequested();
await RunAtTimeOf(DateTime.Now);
}
}
```
Versions of library:
PackageReference Include="Hangfire" Version="1.7.4"
PackageReference Include="Hangfire.AspNetCore" Version="1.7.4"
PackageReference Include="Hangfire.PostgreSql" Version="1.6.0"
Have you tried it with PrepareSchemaIfNecessary =true?
Yeah, sorry i'm blind, it's working =/.
Most helpful comment
Have you tried it with PrepareSchemaIfNecessary =true?