How to Open a Database from Visual Studio Server Explorer in SQL Server?

user1352057 picture user1352057 · May 2, 2015 · Viewed 10k times · Source

Question Background

I have a created a database in Visual Studio under the Server Explorer tab. This is fine but I would like to be able to open this database in SQL Server Management Studio (SQL Server 2008 in this case). I can't see the database under the database list in SQL.

How can I open the database I've created in Visual Studio in SQL Server?

The following diagrams show the issues:

  1. The MainDB.mdf database in VS:

enter image description here

  1. SQL Server 2008 Management Studio. The database MainDB database is not showing:

enter image description here

Answer

yazanpro picture yazanpro · May 2, 2015

You are connecting to two different instances. From Visual Studio, the default instance is either localhost\SQLExpress or just localhost (or just your computer name). From SQL Server Management Studio I can see that you specified something else. From the "Connect to Server" window in SQL Management Studio, choose one of the instances I mentioned above. Or alternatively, from Visual Studio, right click on "Data Connections" --> "Add Connection...", and then specify the same instance name you used to connect using SQL Server Management Studio.