private void SetInitialTableHeights(long targetHeight)
        {
            SetInitialTableHeights();

            // determine which height still need to be transformed
            var minimal = GetMinimalHeight(tableTransformationStates.Values);

            // TODO Do we want this?
            //if (targetHeight < minimal)
            //    throw new ApplicationException("Explorer ledger height is higher than current ledger height. Please wipe the Explorer database!");

            //TODO use batch
            var ledgers = DatabaseService.ReadDatabaseManager.GetLedgersWithStateFromHeight(minimal).ToDictionary(_ => _.Ledger.Ledger.LedgerLight.Height);

            var min = tableTransformationStates.Values.Min(table => table.CurrentHeight);

            for (var height = min + 1; height <= targetHeight; height++)
            {
                Debug.Assert(ledgers.ContainsKey(height));
                var context = new DataTransformationContext(ledgers[height]);

                foreach (var entity in tableTransformationStates.Values)
                {
                    if (entity.CurrentHeight < height)
                    {
                        TransformLedgerState(context, entity.TableName, height);
                    }
                    else if (entity.TableName == "transactiondeclarations")
                    {
                        var declarations = CreateDeclarationContext(context.SignedLedgerState.Ledger, ExplorerDatabaseService.ReadDatabaseManager.GetDeclarations(height));
                        context.SetDeclarations(declarations);
                    }
                }
            }
        }