public bool UpgradeDatabase()
        {
            ISQLDatabase database = ServiceRegistration.Get <ISQLDatabase>(false);
            int          curVersionMajor;
            int          curVersionMinor;

            if (GetDatabaseVersion(out curVersionMajor, out curVersionMinor) &&
                (curVersionMajor < DATABASE_VERSION_MAJOR ||
                 (curVersionMajor == DATABASE_VERSION_MAJOR && curVersionMinor < DATABASE_VERSION_MINOR)))
            {
                //Database was not migratable before version 2.1
                if (curVersionMajor == 2 && curVersionMinor == 0)
                {
                    curVersionMinor = GuessMiniorVersion();
                }

                _upgradeInProgress = true;
                SendUpgradeProgress(0, 100);
                ServiceRegistration.Get <ILogger>().Info("DatabaseManager: Initiating update to database version {0}.{1}", DATABASE_VERSION_MAJOR, DATABASE_VERSION_MINOR);
                Version currrentVersion = new Version(curVersionMajor, curVersionMinor);
                if (database.BackupDatabase(currrentVersion.ToString(2)))
                {
                    SendUpgradeProgress(5, 100);
                    if (database.BackupTables(BACKUP_TABLE_SUFFIX))
                    {
                        SendUpgradeProgress(10, 100);
                        using (ITransaction transaction = database.BeginTransaction(IsolationLevel.Serializable))
                        {
                            ServiceRegistration.Get <ILogger>().Info("DatabaseManager: Creating subschema '{0}'", MediaPortal_Basis_Schema.SUBSCHEMA_NAME);
                            using (TextReader reader = new SqlScriptPreprocessor(MediaPortal_Basis_Schema.SubSchemaCreateScriptPath))
                                ExecuteBatch(transaction, new InstructionList(reader));
                            transaction.Commit();
                        }
                        //A newly created database will always be of the latest version
                        SetDatabaseVersion(DATABASE_VERSION_MAJOR, DATABASE_VERSION_MINOR);

                        //Set MediaLibrary in maintenance mode
                        if (ServiceRegistration.Get <IMediaLibrary>() is MediaLibrary.MediaLibrary mediaLibrary)
                        {
                            mediaLibrary.MaintenanceMode = true;
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }