How to migrate wallet from namecoin to namecore? Today I updated namecoin by building the new "namecore" reimplementation  but when starting namecoind I got this message:

Error opening block database.

Do you want to rebuild the block database now?


and before I could do anything namecoind crashed.
So I moved away the Namecoin folder and let it regenerate everything, blockchain included.
This time it started without errors, so I copied my wallet.dat into the folder and restarted namecoind but I got an Error: and it crashed again.
The debug.log shows this:

2015-06-29 15:36:51 Using wallet wallet.dat
2015-06-29 15:36:51 init message: Verifying wallet...
2015-06-29 15:36:51 CDBEnv::Open: LogDir=/home/michele/Library/Application Support/Namecoin/database ErrorFile=/
2015-06-29 15:36:51 Renamed wallet.dat to wallet.1435592211.bak
2015-06-29 15:36:51 CDBEnv::Salvage: Database salvage found errors,     all data may not be recoverable.
2015-06-29 15:36:51 Salvage(aggressive) found no records in wallet.1435592211.bak.
2015-06-29 15:36:51 Error:


I figured the wallet format has changed somehow, so using the old client I dumped the private keys and I succefully imported them using importprivkey. I can see the address, the balances and all but name_list shows nothing.

How do I get back my names now?
Meanwhile I've answered this question at reddit.

You have already taken the first 2 out of 3 steps necessary for your wallet migration: (1) cleaned up the data directory that contained old incompatible files, (2) dumped and imported the private keys from the old wallet (alternatively, depending on how old the wallet is, one could try starting the new namecore client with the -upgradewallet parameter).
The internal bookkeeping hasn't had a chance to detect the old transactions that belong to the newly imported private keys, yet. This is the missing third step: (3) Restart namecore (i.e. namecoind) with the -rescan parameter.

In short: Now you need to restart the new client with the -rescan parameter.
EDIT: Generally I recommend using namecore's new -upgradewallet parameter:
namecoind -upgradewallet -rescan -reindex
as the dumpprivkey/importprivkey approach always bears the risk of confusing the relevant name_update transactions and addresses with older ones. If you do not know how to use the (deprecated) name_debug1 command in Namecoin-Qt then you most likely get it wrong.