If you happen to receive the exception from the title, then your database probably ended up in an unusable state.
SQL Server provide some options to repair it but it does that with the risk of potentially losing data.
The syntax that I used to repair it is the following:
ALTER DATABASE MyBrokenDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DBCC CHECKDB ('MyBrokenDB ', REPAIR_ALLOW_DATA_LOSS);
ALTER DATABASE MyBrokenDB SET MULTI_USER;
In my particular case, it worked without breaking anything.
By the way, try to execute the entire script block at once. I tried first the DBCC CHECKDB statement but then I got some back and forth exceptions about MULTI_USER/SINGLE_USER modes.
You can read more about the DBCC CHECKDB options here.