SQL Server 对象资源管理器未显示数据库

问题描述 投票:0回答:3

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

PM> update-database -Verbose

使用启动项目“ChattyServer”。
使用 NuGet 项目“ChattyDataModel”。
目标数据库是:“ChattyDataModel.ChattyContext”(数据源:.\SQLEXPRESS,提供程序:System.Data.SqlClient,来源:Convention)。
没有待处理的显式迁移。
运行种子方法。

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

UPD

app.config
- 我应该使用哪个连接字符串来
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 对象资源管理器中没有任何更改

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

c# sql-server entity-framework ef-code-first
3个回答
7
投票

首先:您正在使用Master数据库。查看这篇文章以了解如何设置连接字符串:无法找到我的 EF Code First 数据库。

其次:您没有连接到

SQLEXPRESS

  • 在服务器资源管理器中单击“连接到数据库”。

  • 然后在服务器名称中输入

    .\sqlexpress

  • 然后测试连接。

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


0
投票

我遇到了同样的问题,发现我没有将 SSOX 连接到正确的 SQL Server 实例。我连接了旧的完整版本,而不是 SQL Express。该程序运行完美,但无法在我正在查看的数据库上运行!

我连接到(我的电脑)\SQLExpress,瞧!我可以看到我的数据库! 拍额头

希望能帮助其他遇到同样问题的人。


0
投票
  1. 搜索sql server explorer
  2. 右键单击 - 然后单击添加 sql Server
  3. 点击浏览水龙头
  4. 本地 > 您可以在本地下方找到您的服务器名称。
  5. 信任服务器证书 - True

那么你就可以走了:)

© www.soinside.com 2019 - 2024. All rights reserved.