Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 724
small-j Avatar asked May 05 '16 19:05

small-j


1 Answers

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.

like image 88
Salah Akbari Avatar answered Oct 15 '22 09:10

Salah Akbari