@@ -10,7 +10,9 @@ This Source Code Form is subject to the terms of the
1010using Microsoft . EntityFrameworkCore ;
1111using Microsoft . Extensions . Configuration ;
1212using Microsoft . Extensions . DependencyInjection ;
13+ using Microsoft . Extensions . Logging ;
1314using Microsoft . Extensions . Options ;
15+ using OneScript . WebHost . Application ;
1416using OneScript . WebHost . Infrastructure ;
1517using ScriptEngine ;
1618
@@ -22,9 +24,6 @@ public static class DatabaseExtensions
2224
2325 public static void AddDatabaseByConfiguration ( this IServiceCollection services , IConfiguration config )
2426 {
25- if ( ! config . GetChildren ( ) . Any ( item => item . Key == ConfigSectionName ) )
26- return ;
27-
2827 var dbSettings = config . GetSection ( ConfigSectionName ) ;
2928
3029 // Делаем доступным для прочих частей приложения
@@ -70,9 +69,11 @@ private static DbContextOptions<ApplicationDbContext> ConfigureDbOptions(IServic
7069
7170 public static void PrepareDbEnvironment ( IServiceProvider services , RuntimeEnvironment environment )
7271 {
72+ var logger = services . GetService < ILogger < ApplicationInstance > > ( ) ;
7373 var dbOptions = services . GetService < IOptions < OscriptDbOptions > > ( ) . Value ;
7474 if ( dbOptions != null && dbOptions . DbType != SupportedDatabase . Unknown )
7575 {
76+ logger . LogDebug ( $ "Database enabled: { dbOptions . DbType } ") ;
7677 var dbctx = services . GetService < ApplicationDbContext > ( ) ;
7778 dbctx . Database . EnsureCreated ( ) ;
7879
@@ -86,6 +87,10 @@ public static void PrepareDbEnvironment(IServiceProvider services, RuntimeEnviro
8687 environment . InjectGlobalProperty ( ib , "ИнформационнаяБаза" , true ) ;
8788 environment . InjectGlobalProperty ( ib , "InfoBase" , true ) ;
8889 }
90+ else
91+ {
92+ logger . LogDebug ( "No database configured" ) ;
93+ }
8994 }
9095 }
9196
0 commit comments