Use a more elegant method of setting the connection timeout

This commit is contained in:
Dean Herbert 2017-10-22 16:18:19 +09:00
parent 9aa46bfb0d
commit 1514d8451e
1 changed files with 2 additions and 3 deletions

View File

@ -3,6 +3,7 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
using osu.Framework.Logging;
@ -50,8 +51,6 @@ public OsuDbContext(string connectionString)
{
this.connectionString = connectionString;
Database.SetCommandTimeout(new TimeSpan(TimeSpan.TicksPerSecond * 10));
var connection = Database.GetDbConnection();
connection.Open();
using (var cmd = connection.CreateCommand())
@ -68,7 +67,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
// this is required for the time being due to the way we are querying in places like BeatmapStore.
// if we ever move to having consumers file their own .Includes, or get eager loading support, this could be re-enabled.
.ConfigureWarnings(warnings => warnings.Ignore(CoreEventId.IncludeIgnoredWarning))
.UseSqlite(connectionString)
.UseSqlite(connectionString, sqliteOptions => sqliteOptions.CommandTimeout(10))
.UseLoggerFactory(logger.Value);
}