MSSQLLOCALDB databases aren't listed
Asked Answered
A

5

15

I used the ASP.NET 5 Preview Templates in Visual Studio 2015 to create an ASP.NET 5 site. According to the config.json file, there's a database in (localdb)\mssqllocaldb.

I want to move that database to my actual SQL Server, but when I connect to the (localdb)\mssqllocaldb server in SQL Server Management Studio to start the backup process, there are no databases listed. Where is it?

Any idea on how I can migrate that database if I can't find it in SSMS?

April answered 1/12, 2015 at 20:17 Comment(0)
A
1

On the "Connect to Server" login, there is an "Options" button. That opens a "Connection Properties" tab that lets you find specify a database, either by manually entering the name or browsing for it. When connecting that way, it does appear in the list.

April answered 1/12, 2015 at 22:9 Comment(2)
Just add the complete connection string - worked for me: (localdb)\MSSQLLocalDbStopper
In visual Studio 2019/2022, in 'Server Explorer' toolbar at the top, click on 'SQL Server Object Explorer' icon. The databases will then show up under 'Sql Server' tree. If your database is not listed in VS 2019, try with VS 2022.Silkworm
H
29

I had this problem also and just got it working (I'm doing the MVC-Movie MVC6 Tutorial - i'm just at the 'Adding a Model' section where you create a connection to a Local Database : here).

Visual Studio 2015/SQL Server 2014 uses a different path than 2012/2013. I previously had VS2012 and VS2013 installed and had created local databases in each. VS2012 created a connection as: (localdb)\v11.0 and SQL Server Data Tools (SSDT) as (localdb)\ProjectsV12.

To get the (LocalDB)\MSSQLLocalDB working you:

  1. Open CMD Prompt and type SQLLocalDB.exe info this shows all the current database servers on your local connection
  2. You should see an option here for MSSQLLocalDB. type SQLLocalDB.exe start MSSQLLocalDB It will tell you that this has now been started.
  3. Go to Visual Studio and click View -> SQL Server Object Browser From here you will need to add a SQL Server (right click on SQL Server and 'Add SQL Server'
  4. In Server name: field enter '(LocalDB)\MSSQLLocalDB' - the Username/Servertype/Authentication should be left as default. Upon clicking Connect, the new database will show up with your new database

Databases are now stored in c:\users\[DATABASE-NAME] where as previously they were stored in your C:\Users\\AppData\Local\Microsoft\VisualStudio\SSDT

Hopefully this solves your issue with finding the SQLServer, Cheers

Hawsepiece answered 14/12, 2015 at 10:59 Comment(5)
A quick note: in the latest SSDT Preview for VS2015 there is now support for seeing & connecting to any LocalDB instances on your machine from the Connection Dialog used by SQL Server Object Explorer (Step 3). So you should no longer needto manually type in & verify the LocalDB server name. Might save you some of the manual work listed here. Download is at msdn.microsoft.com/en-us/library/mt204009.aspxCameo
Excellent Kevin, that is super handy for managing the LocalDbs. Cheers !Hawsepiece
This works, thanks. Just to correct a typo in Step 2: SQLLocalDB.exe start MSSQLLocalDBKerns
I wondered why my DB appeared to be failing silently on creation!! Turns out EF's Database.EnsureCreated() was doing exactly what it was supposed to, just the db wasn't being listed is all. All the tutorials I looked at completely omitted this important detail, thanks for figuring this out!Dennadennard
This doesn't work if the database was created using a different Window's user.Toreutic
G
4

I encountered something different, I could see the (LocalDb)\MSSQLLocalDB in the SQL Object Explorer in Visual Studio although I could not see it in the SSMS. So I followed @Maxithi and @JohnYoungTree response to start the LocalDB instance

To get the (LocalDB)\MSSQLLocalDB working you:

  1. Open CMD Prompt and type SQLLocalDB.exe info this shows all the current database servers on your local connection
  2. You should see an option here for MSSQLLocalDB. type SQLLocalDB.exe start MSSQLLocalDB It will tell you that this has now been started.

After this, I went to SSMS and clicked on Connect, then I input Server Name as (LocalDb)\MSSQLLocalDB and I used my Windows Authentication. This worked awesomely!

Thank you @Maxithi and @JohnYoungTree

Greeting answered 15/6, 2019 at 23:17 Comment(0)
A
1

On the "Connect to Server" login, there is an "Options" button. That opens a "Connection Properties" tab that lets you find specify a database, either by manually entering the name or browsing for it. When connecting that way, it does appear in the list.

April answered 1/12, 2015 at 22:9 Comment(2)
Just add the complete connection string - worked for me: (localdb)\MSSQLLocalDbStopper
In visual Studio 2019/2022, in 'Server Explorer' toolbar at the top, click on 'SQL Server Object Explorer' icon. The databases will then show up under 'Sql Server' tree. If your database is not listed in VS 2019, try with VS 2022.Silkworm
A
0

The problem I encountered was that someone didn't specify an Initial Catalog in the connection string. Since database migrations were running to created the database, it was working; however, I could not find a database. I finally found all the tables in the master database. Afterwards, I corrected the connection string from:

Server=(localdb)\\MSSQLLocalDB;Integrated Security=true

to

Server=(localdb)\\MSSQLLocalDB;Integrated Security=true;Initial Catalog=MyDatabaseName
Arakawa answered 16/8, 2021 at 15:39 Comment(0)
M
-2
//...for entity
public class ogrenciCONTEXT:DbContext
{
    public ogrenciCONTEXT():base("sqlim")
    {
    }
    public DbSet<ogrenci> ogrenciler { get; set; }
}

// for WEB CONFIG 
<connectionStrings>
    <add name="sqlim"
      connectionString="Data Source=(LocalDB)\mssqllocaldb;initial catalog=dosyaismi; Integrated Security=True"
 providerName="System.Data.SqlClient"/>
</connectionStrings>
Materiel answered 26/11, 2016 at 19:54 Comment(1)
Does not answer the question.April

© 2022 - 2024 — McMap. All rights reserved.