• I had this error when trying to attach a db on my SQL Server 2012 instance connected using Windows credentials. What fixed the problem was giving full control of the mdf and ldf files to this user.

    Right click the folder containing mdf and ldf files, Go to Properties --> Security tab --> Edit --> Scroll down to the user and select Allow under full control permissions --> Click Apply.