示例#1
0
        private void InitDatabaseIfNeeded(IApplicationBuilder app)
        {
            app.EnsureDatabase(connStr =>
            {
                _startupLogger.LogCritical("正在创建新的数据库结构...");

                var loggingConfig = _appConfiguration.GetSection(WebHostConfiguration.ConfigKeyLogging);
                SqliteMigrator.Migrate(connStr, migrationLogging =>
                                       FileLoggingExtensions.AddSeriFileLogger(migrationLogging, loggingConfig /* enable full logging for migrations */));

                _startupLogger.LogCritical("数据库结构创建完成");
            }, _startupLogger);
        }
示例#2
0
        private void InitDatabaseIfNeeded(IApplicationBuilder app)
        {
            app.EnsureDatabase(connStr =>
            {
                if (!connStr.IsForTemporaryDatabase())
                {
                    return;
                }

                _startupLogger.LogCritical("正在创建和更新数据库结构...");

                var loggingConfig = _appConfiguration.GetSection(WebHostConfiguration.ConfigKeyLogging);
                DatabaseMigrator.Migrate(connStr, migrationLogging =>
                                         FileLoggingExtensions.AddSeriFileLogger(migrationLogging,
                                                                                 loggingConfig /* enable full logging for migrations */));

                _startupLogger.LogCritical("数据库结构创建并更新完成");
            }, _startupLogger);
        }