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

sma*_*l-j 6 c# sql-server entity-framework ef-code-first

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

PM> update-database -Verbose
Run Code Online (Sandbox Code Playgroud)

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

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

UPDapp.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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

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

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

Sal*_*ari 7

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

其次:您没有连接到SQLEXPRESS

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

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

  • 然后测试连接。

  • 然后在 Select or enter a database name 你应该得到你的数据库。