diff --git a/MailSender/Notify.cs b/MailSender/Notify.cs index 23e2730..84a7beb 100644 --- a/MailSender/Notify.cs +++ b/MailSender/Notify.cs @@ -1,4 +1,3 @@ -using System.Configuration; using System.Text; using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.Configuration; diff --git a/Mundialito/DAL/MundialitoDbContext.cs b/Mundialito/DAL/MundialitoDbContext.cs index 61af3dd..85a96cd 100644 --- a/Mundialito/DAL/MundialitoDbContext.cs +++ b/Mundialito/DAL/MundialitoDbContext.cs @@ -131,6 +131,24 @@ protected override void OnConfiguring(DbContextOptionsBuilder options) } else { + var db = appConfig.GetSection("App").GetValue("DBType", DBTypeEnum.SQLLite); + switch (db) + { + case DBTypeEnum.PostgreSQL: + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); + options.UseNpgsql(_connectionString); + break; + case DBTypeEnum.SQLServer: + options.UseSqlServer(_connectionString, b => b.EnableRetryOnFailure()); + break; + case DBTypeEnum.SQLLite: + options.UseSqlite(appConfig.GetConnectionString("App")); + break; + default: + throw new Exception("Unknown DB type"); + } + options.UseSqlServer(_connectionString, b => b.EnableRetryOnFailure()); } }