“One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.”
If the Data files and Transaction Log files belong to different backups or if they belong to different databases, an error message can be received.
For example, imagine you have a database named “x”. Consider that the backup is taken directly as * .mdf \ ndf and * .ldf.
If you combine data files from 30.09.2009 and Transaction Log files dated 01.10.2009, you will see this error message if you try to attach the database in this way.
You must match the correct Data and Transaction Log files and attach them.