Restore failed when MDF file name is claimed

When restoring databases to a new instance of SQL Server, you may encounter an error similar to the following:


Restore failed for Server <MyServer>

Additional information:System.Data.SqlClient.SqlError: File: 
'C:\Program Files\Microsoft SQL Server\
MSSQL10_50.MSSQLSERVER\MSSQL\DATA\RL_REPORTS.mdf' is claimed by 'DATA'(3) and
'PRIMARY'(1). The WITH MOVE clause can be used to relocate one or more files. 
(Microsoft.SqlServer.Smo)

The above issue is caused by the SQL Server restore procedure that converts all of the Discover database names to RL_REPORT.mdf. This situation is typically caused when the new location has a different directory structure or when the databases are moved to a new version of SQL Server.

The solution is to manually append the file name of each data file to include the Filegroup identifier for the file to the end of the file name.