Microsoft Visual Studio 2012 - Converting SQL Server Express database to LocalDB

When you open an old project in visual studio 2012 that contains a SQL Server Express DataBase you may get the following message:

The Web project ‘Project Name’ requires SQL Server Exress, which is not installed on this computer. The recommended database engine for Visual Studio 2012 is SQL Server LocalDB Express. To upgrade the project database to use SQL Server LocalDB Express, double-clisk the database file and follow the instructions. Note: After this upgrade, the project database can’t be modified using earlier versions of Visual Studio. To use SQL Server Express for this project, install it from the Microsoft Download Center.

To fix this without installing SQL Server Express you need to use Microsoft’s new LocalDB Express, the stages involved are:

  1. Modify the data connection

  2. Copy the new connection details to your web.config

OK first open the server explorer from the view menu

Then right click on the database file and select modify connection

Then you need to select Microsoft SQL Server Database File as your data source and make sure the correct path is selected for your database file (this is important to check, it may be wrong if you have downloaded the solution from the internet)

Now select advanced and change the datasource to (LocalDB)\v11.0 and the User Instance to false

Now test your connection and view the connection string in the properties of the database by right clicking on the database in server explorer  

Now you can copy the connection string into your web.config file and remember to replace the filepath with |DataDirectory| if the database is in the app_data folder

If you have done any of the above wrong you might see the following error messages:

————————— Microsoft Visual Studio —————————

The attempt to attach to the database failed with the following information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist. )

————————— OK —————————

or

————————— Microsoft Visual Studio —————————

This database file is not compatible with the current instance of SQL Server. To resolve this issue, you must upgrade the database file by creating a new data connection, or you must modify the existing connection to this database file. For more information, see http://go.microsoft.com/fwlink/?LinkId=235986

————————— OK   —————————

http://msdn.microsoft.com/en-us/library/hh873188(v=vs.110).aspx http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx

comments powered by Disqus