EPiServer: Attach Database Failed – Access is Denied

I wanted to explore the EPiServer 8.0 database and so I went to clone the MDF file located within my solution and placed the copy in a backup folder. I then went to open SQL Management studio and tried attaching the MDF file:

1. Right Click on the Databases folder
2. Click ‘Attach’
3. Find the ‘Add’ button and click it where a File Browser window will open
4. Locate the file and click OK

However, I got an error along the lines of: “Attach Database failed – Unable to open the physical file – Access is denied”

Two things I did to make it work:

1. Move the .mdf file to the correct SQL path

I moved the mdf file to the following path (I’m using SQL Express):
C:Program FilesMicrosoft SQL ServerMSSQL11.SQLEXPRESSMSSQLDATA
For the full SQL, it should be something like:
C:Program FilesMicrosoft SQL ServerMSSQL11.SS2012MSSQLDATA

And then did the same steps to attach a DB file above. However, I was still getting the same error. So I went to try this next step

2. Run SQL Server Management Studio as Admin. Did the same steps as above and voila. It worked.

I tried doing only step 2 without 1 but it fails. So the solution is basically a combo of both steps.

Leave a Reply

Your email address will not be published. Required fields are marked *