0

I have the problem that I am using Visual Studio 2013 to create a MDF file and then open it like it is described in this tutorial:

creating-the-membership-schema-in-sql-server

But when I try to attach the database to the MSSQLServer I get error 948 which basicly says:

The database cannot be opened because it is version 706. This server supports version 663 and earlier.

I have read these two articles:

The database cannot be opened because it is version 782. This server supports version 706 and earlier. A downgrade path is not supported

The database cannot be opened because it is version 706. (ASP.net)

From this is assume that it is possible to switch "Visual Studio" to a different SQL Server Version. So I could delete my old file, create a new one (In vS2013 ) and then attach it to my SQlServerExpress.

Could I switch under

Tools-> Options -> Database Tools -> Data Connections

to SQL version (LocalDB)\v10.0 ? And if so are there any reasons to not switch because it could lead to errors or unexpected behavior in VS2013

Community
  • 1
  • 1
Bongo
  • 2,933
  • 5
  • 36
  • 67
  • Classic error (it means someone created/(or updated) the database using a newer version then you can support) Not much you can do with it with the exception of upgrading. (the simplest solution is always to mount/connect the DB to a SQL server and use the connection string and connect to it via that) – Thomas Andreè Wang Apr 08 '16 at 12:38
  • I wanted to know if it is possible to create a new mdf file from visual studio with a different version – Bongo Apr 08 '16 at 12:39
  • Yes it is. rightclick -> add -> databasefile (it will be empty though, you should take a look at EntityFramework Code first Migration – Thomas Andreè Wang Apr 08 '16 at 12:45

1 Answers1

3

When you create a database, you can specify the compatibility version. This turns off features that would be available in a newer version of SQL Server, but it is unlikely that you would be using those if you just have a database for authentication.

It appears that only SQL Server Express version 2008 R2 (with some patches applied) in your problem server. To create your database in a compatible version, you have to go through many steps (full article):

  • Backup your current database
  • In the Database Manager, right click and choose the "Generate Scripts" task:
    • Script entire database
    • Save to file and choose your destination path, choose Unicode text file
    • Select the following advanced options:
    • Script for Server Version: SQL Server 2008 R2
    • Types of data to script: schema and data
    • Script Foreign Keys: true
    • Script Indexes: true
  • Connect to a SQL Server 2008 R2 instance (important)
  • Run the scripts you generated to recreate the database and data in the downgraded version (you may have to correct the database name in the top of the script)
  • Take the generated MDF file and incorporate it in your application

A newer database can work with an older MDF file (within reason, Server 2012 won't go further back than 2008), but it won't be able to create an MDF file that is compatible with an older version.

Berin Loritsch
  • 11,400
  • 4
  • 30
  • 57