Error : The attach operation cannot continue because another object in this farm already contains the same ID

In SharePoint 2013. I tried to remove the content DB from the web application by using the remove database option.
after this, I tried to add the content database to the same web application again, but I was continuously getting the error : "The attach operation cannot continue because another object in this farm already contains the same ID"

I found some powershell, through which you can get rid of this problem. it is for sure that the content DB is attached to the web application but some how it is not visible and that's why I was not able the content DB to the web application.

To check if the Database is already connected to the web application, use the below PS command.

Get-SPDatabase | where{$_.Name -eq “Name of your WEB Application“}

This PS will give you the result, if the content DB is already attached.the details provided by this command 
ID
Name
Web Application
Server
Current Site count.

Now you can take the ID of this content DB and use the below command to remove this DB from Web application.
Note: You can also use name but sometime name doesn't work properly.


Dismount-SPContentDatabase 12345678-90ab-cdef-1234-567890abcdef
http://technet.microsoft.com/en-us/library/ff607764.aspx
 
This way it will dismout the content DB and now you can add the 
content DB to the web application from central admin or use the below
command to mount it
Mount-SPContentDatabase “MyDatabase” -DatabaseServer "MyServer" -WebApplication http://sitename
http://technet.microsoft.com/en-us/library/ff607581.aspx