ASP.Net Core + SQLite "Could not find connection string"
Hi everyone !
I'm trying to use Hangfire.SQLite in an ASP.Net Core app (2.1.1) but I have the following error :
Could not find connection string with name 'Filename=./mydb.db' in application config file
Which is weird because in Startup.ConfigureServices() I use the db with services.AddDbContext<DataContext>(options => options.UseSqlite(@"Filename=./mydb.db")); and it's working fine with the exact same connection string.
I'm configuring Hangfire like this :
var sqliteOptions = new SQLiteStorageOptions();
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
//.UseMemoryStorage(new MemoryStorageOptions { JobExpirationCheckInterval = TimeSpan.FromMinutes(10) })
.UseSQLiteStorage("Filename=psm.db", sqliteOptions)
);
services.AddHangfireServer();
As you can see, I've tested with the MemoryStorage extension and it works well, I have the dashboard and Jobs are executed successfully.
For information I've also tried the absolute path with Data Source instead of Filename, I've tried adding HangfireConnection key in appsettings.json etc. but always got the same error.
Thx for the help.
I've finally found a solution. The reason why it's not working is weird IMO : you need to have a ; in your connection string.
You can find the responsible line here : https://github.com/wanlitao/HangfireExtension/blob/master/src/Hangfire.SQLite/SQLiteStorage.cs#L308
So adding a ; at the end of the string solved my problem.
I can confirm this works in after adding ";" at the end of the connection string.
I dicked with this for hours. Who would have known ";" was the issue :(
Had this issue as well. I had to put it in the json file itself or it would throw another error
I can confirm this works in after adding ";" at the end of the connection string.
my problem solved ,tankyou
Thanks!
I've finally found a solution. The reason why it's not working is weird IMO : you need to have a ; in your connection string.
You can find the responsible line here : https://github.com/wanlitao/HangfireExtension/blob/master/src/Hangfire.SQLite/SQLiteStorage.cs#L308
So adding a ; at the end of the string solved my problem.
thank you this actually worked 👍🥰