This error can also occur when trying to generate a database from a script. I was trying to do downgrade a SQL Server 2012 database to 2008 as per this article https://superuser.com/questions/468578/move-database-from-sql-server-2012-to-2008. However, when I ran the script initially, I got this error
The logical file name "emmagarland" is already in use. Choose a different name.
Turns out (after reading this article https://ask.sqlservercentral.com/questions/106577/the-logical-file-name-database-is-already-in-use.html) in my restore script, I hadn't checked and changed the logical file names. I had to ensure the path is correct, and the change the generated name for the log file, else it tries to overwrite the .mdf file with the log and then throws this error. I fixed it by changing the name from xxxxx to xxxxxldf
CREATE DATABASE [xxxxx] ON PRIMARY
( NAME = xxxxx', FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\xxxxx.mdf' , SIZE =
14400KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'xxxxxldf', FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\xxxxx_log.ldf' ,
SIZE = 18560KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
Sounds simple but I couldn't work out why this error was occuring when I was creating a brand new database!
myDB, you can use the MSSMS activity monitor to see which connection/user is on that DB.