small-j
small-j

Reputation: 309

SQL Server Object Explorer not showing a database

It's a very small code-first EF6 Project. I added a migration and updated a database successfully. Here's the output:

PM> update-database -Verbose

Using StartUp project 'ChattyServer'.
Using NuGet project 'ChattyDataModel'.
Target database is: 'ChattyDataModel.ChattyContext' (DataSource: .\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
No pending explicit migrations.
Running Seed method.

However, when I open the SQL Server Object Explorer, I can't find my database: No ChattyDataModel.ChattyContext shown

UPD: The app.config - which connection string should I use for LocalDb?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" 
             type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

UPD: Updated the app.config, added:

<connectionStrings>
    <add name="DbConnect" 
         connectionString="Data Source=(localdb)\ProjectsV13;Initial Catalog=master;Integrated Security=True;ConnectTimeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" />
</connectionStrings>

Then created a new migration and updated a database. No changes in the SQL Server Object Explorer

UPD I changed the directory from master to chatty, created a new migration and updated the db-still can't see db in the SQL Server Object Explorer

Upvotes: 6

Views: 17001

Answers (3)

Yousef Obeidat
Yousef Obeidat

Reputation: 1

  1. Search for SQL Server explorer
  2. Right click - then click Add SQL Server
  3. Click on browse tap
  4. Local > you can find your server name listed below local.
  5. Trust server certificate - True

Upvotes: 0

Ray
Ray

Reputation: 1

I had the same problem and found that I hadn't connected SSOX to the right instance of SQL Server. I had my older full version connected, not the SQL Express. The program was functioning perfectly but not on the db I was looking at!

I connected to (my pc)\SQLExpress and voila! I could see my database! slaps forehead

Hope that helps someone else with the same problem.

Upvotes: 0

Salah Akbari
Salah Akbari

Reputation: 39946

Firstly: You are using the Master database. Check this post to know how to set your connection string: Cant find my EF code first database.

Secondly: You didn't connect to SQLEXPRESS:

  • In your Server Explorer click on Connect to Database.

  • Then in the Server name type .\sqlexpress

  • Then Test Connection.

  • then in the Select or enter a database name you should get your database.

Upvotes: 7

Related Questions