SQL Server对象资源管理器不显示数据库 [英] SQL Server Object Explorer not showing a database

查看:2170
本文介绍了SQL Server对象资源管理器不显示数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常小的代码优先的EF6项目。我添加了一个迁移并成功更新了一个数据库。以下是输出:

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




使用StartUp项目ChattyServer。 >
使用NuGet项目'ChattyDataModel'

目标数据库是:'ChattyDataModel.ChattyContext'(DataSource:.\SQLEXPRESS,Provider:System.Data.SqlClient,Origin:Convention) br>
没有等待显式迁移。

运行种子方法。

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.

然而,当我打开SQL Server对象资源管理器,我找不到我的数据库:

However, when I open the SQL Server Object Explorer, I can't find my database:

UPD c code应用程序应该用于 LocalDb

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 :更新了 app.config ,添加:

<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>

然后创建了一个新的迁移并更新了一个数据库。没有更改SQL Server对象资源管理器

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

UPD 我将目录从主机更改为chatty,创建了一个新的迁移并更新了db-still在SQL Server对象资源管理器中看不到数据库

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

推荐答案

首先:您正在使用主数据库。检查此信息以了解如何设置连接字符串:无法找到我的EF代码数据库

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.

其次:您没有连接到 SQLEXPRESS


  • 在您的服务器资源管理器中,单击连接到数据库。

  • In your Server Explorer click on Connect to Database.

然后在服务器名称类型 .\sqlexpress

Then in the Server name type .\sqlexpress

然后测试连接。

然后在选择或输入数据库名称中,您应该得到
数据库。

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

这篇关于SQL Server对象资源管理器不显示数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆