If when you try to open a database or attaching a .mdf file you get the error:
is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
So here is the algorithm I followed to solve this issue:
1. only if an existing database gives this error detach the database – right click -> Detach
2. closed all SQL Server Management Studio instances
3. Stop the SQL Server service.. (Start->Run -> services.msc)
4. Selected .mdf file(should be blue if compressed ) Right click properties -> Advanced -> Uncheck "Compress files to save disk space"
5.(re)attach .mdf file