6

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

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
small-j
  • 309
  • 1
  • 4
  • 12

2 Answers2

7

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.

Community
  • 1
  • 1
Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
  • I am doing all that, and after selecting a valid db, it doesn't still show up in the Server Explorer tool box – Jitin Apr 26 '21 at 10:50
0

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.

Ray
  • 1