Hi Bhupinder,
According to my knowledge, the above error could occur when the database is corrupt. If you have backup of the database, you can follow the steps in this similar
blog to restore the database to localdb/mssqllocaldb
instance.
However, if you dont have the backup, execute the following scripts to restore database.
CREATE DATABASE [MATERIALSDB]
ON (FILENAME = 'c:\wherever\ MATERIALSDB.mdf')
FOR ATTACH_REBUILD_LOG;
If that fails, perform the following process and check if it works.
on your localdb/mssqllocaldb instance, create a database with a data file of the exact same size
shutdown SQL Server
rename the new database's mdf file, and paste the old one in its place
bring up the server and let the database attempt to be recovered and then go into suspect mode
put the database into emergency mode with ALTER DATABASE MATERIALSDB SET EMERGENCY
run DBCC CHECKDB (MATERIALSDB, REPAIR_ALLOW_DATA_LOSS); which will rebuild the log and run full repair
There is a similar thread for your reference.
http://dba.stackexchange.com/questions/42762/how-to-attach-an-mdf-file-that-was-not-properly-detached/42807#42807
Thanks,
Lydia