The database ‘file.mdf’ cannot be opened because it is version 655

| December 28, 2010 | 0 Comments

Problem:

This was weird & probably first problem I faced related to Sql Server version(s). I was trying to learn Asp MVC with the help of sample application MvcMusicStore. I open it in VS 2010 and debug. On debugging it throw runtime exception:

System.Data.EntityException was unhandled by user code.
Message=The underlying provider failed on Open.
Source=System.Data.Entity
…………….
InnerException: System.Data.SqlClient.SqlException
Message=The database ‘X:\MVCMusicStore\App_Data\MvcMusicStore.MDF’ cannot be opened because it is version 655. This server supports version 611 and earlier. A downgrade path is not supported.
Could not open new database ‘X:\MVCMusicStore\App_Data\MvcMusicStore.MDF’. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file X:\SomeFolder\MVC Music Store COMPLETE\MvcMusicStore-Completed\MvcMusicStore\App_Data\MvcMusicStore.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=20
LineNumber=65536
Number=948
Procedure=””
Server=\\.\pipe\9CEF06E2-A18C-41\tsql\query
State=1

Solution:

The reason for exception was that MvcMusicStore application’s database files (.mdf) were created with Sql Server 2008 (version 655). While the application was trying to attach database file with Sql Server 2005 (version 611) instance. And since there is compatibility issues in these two versions so the exception was raised.

To solve this problem you can follow either of the steps:
    1. Upgrade Sql Server 2005 to Sql Server 2008 and create same database files in Sql Server 2008 (as Sql Server 2008 adds metadata to the resulting .mdf files).
    2. Or you can install fresh version of Sql Server 2008 along with Sql Server 2005. BUT since you are (now) having two versions of Sql Server you would need to modify DataSource in connectionString with SqlServer 2008 instance name (.\VSS is instance name I created for… it could be any except sa as it is already there in system)in web.config as follows:



Tags: ,

Category: Error and Solution

Leave a Reply

%d bloggers like this: