When you attach a database you might get the error below.
——————————————————————————————————————–
Unable to open the physical file “C:\Database\Commerce.mdf”. Operating system error 5: “5(Access is denied.)”. (Microsoft SQL Server, Error: 5120)
——————————————————————————————————————–
What you need to do is to assign the right to the Users account. Of course this is one of the developmentās ways. You might want to set for a specific user account for deployment.
I had this issue and all the solutions online was kind of misleading to my issue. I have the solution here.
http://dotnet-programming-solutions.blogspot.com/2012/10/attach-database-encountered-operating.html
The solution was to Run SSMS as Administrator.