How to: Upgrade to LocalDB or Continue with SQL Server Express
This topic describes your options for upgrading your database file (.mdf) after you install Visual Studio 2012 and includes instructions for the following tasks:
Upgrade a database file to use LocalDB
Upgrade a database file to use a newer version of SQL Server Express
Work with a database file in Visual Studio 2012 but retain compatibility with SQL Server 2008 Express
Make SQL Server Express the default database engine
You can use Visual Studio 2012 to open a project that contains a database file (.mdf) that was created by using an older version of SQL Server Express. However, to continue to develop your project in Visual Studio 2012, you must either have that version of SQL Server Express installed on the same machine as Visual Studio, or you must upgrade the database file to use SQL Server Express LocalDB. If you upgrade the database file, you won't be able to access it with older versions of SQL Server Express.
You may also be prompted to upgrade a database file that was created by using SQL Server 2012 Express if the version of the file isn't compatible with the instance of SQL Server Express that’s currently installed. To resolve the issue, Visual Studio will prompt you to upgrade the file to the newer version of SQL Server Express.
We recommend that you back up the database file before you upgrade it.
Before you upgrade a database, you should consider the following criteria:
Don't upgrade if you want to work on your project in both Visual Studio 2010 and Visual Studio 2012.
Don't upgrade if your application will be used in environments that use SQL Server Express rather than LocalDB.
Don't upgrade if your application uses remote connections because LocalDB doesn't accept them.
Don't upgrade if your application relies on Internet Information Services (IIS).
Consider upgrading if you want to test database applications in a sandbox environment but don't want to administer a database.
To upgrade a database file to use LocalDB
In Server Explorer, choose the Connect to Database button.
In the Add Connection dialog box, specify the following information:
Data Source: Microsoft SQL Server (SqlClient)
Server Name: (LocalDB)\v11.0
Attach a database file:Path, where Path is the physical path of the primary .mdf file.
Logical Name:Name, where Name is the name that you want to use with the file.
Choose the OK button.
When prompted, choose the Yes button to upgrade the file.
The database is upgraded, attached to the LocalDB database engine, and no longer compatible with SQL Server 2008 Express.
You can also modify a SQLExpress connection to use LocalDB by opening the shortcut menu for the connection and then choosing Modify Connection. In the Modify Connection dialog box, change the server name to (LocalDB)\v11.0. In the Advanced Properties dialog box, make sure that User Instance is set to False.
To upgrade to a newer version of SQL Server Express
In the shortcut menu for the connection to the database, choose Modify Connection.
In the Modify Connection dialog box, choose the Advanced button.
In the Advanced Properties dialog box, choose the OK button without changing the server name.
The database file is upgraded to match the current version of SQL Server 2012 Express.
To work with the database in Visual Studio 2012 but retain compatibility with SQL Server 2008 Express
In Visual Studio 2012, open the project without upgrading it.
To run the project, choose the F5 key.
To edit the database, open the .mdf file in Solution Explorer, and expand the node in Server Explorer to work with your database just as you did in Visual Studio 2010.
To make SQL Server Express the default database engine
On the menu bar, choose Tools, Options.
In the Options dialog box, expand the Data Tools options, and then choose the Data Connections node.
In the SQL Server Instance Name text box, specify the name of the instance of SQL Server Express that you want to use. If the instance isn't named, specify .\SQLEXPRESS.
Choose the OK button.
SQL Server Express will be the default database engine for your applications.