I had this issue when I tried to swap the databases after bacpac restore.
“Could not rename the database ‘DbName’. The database is in single-user mode, and a user is currently connected to it”
Given below the steps I followed to address this error
SELECT request_session_id FROM sys.dm_tran_locks
WHERE resource_database_id = DB_ID('DbNameWithQuotes')
On executing this statement, the output will be given with ‘request_session_id’. Copy the value and use it in the next statement. No quotes needed in the next command
kill spid_value
Execute the last command to enable the database in multi-user mode
use master;
GO
ALTER DATABASE YourDbName SET MULTI_USER
GO
Go to the database node in SSMS and click refresh. You can see there will be no errors.