entity-framework - Entity Framework 代码优先默认数据库位置

标签 entity-framework visual-studio-2012

我正在尝试关注 http://msdn.microsoft.com/en-us/data/jj193542 上的视频教程使用 Visual Studio 2012 Express for Desktop。

我创建了 POCO 和一个 DbContext,运行了一些示例查询并且它起作用了。但我没有提供任何连接字符串。那么数据库在哪里呢? (可能是 sdf 或 mdf 文件?)

在教程中,该人使用 SQL Server 对象资源管理器查看数据库,但我在 VS Express 中找不到该 View 。

作为引用,这里是生成的默认 App.config。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.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>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>

最佳答案

“如果安装了 SQL Express(包含在 Visual Studio 2010 中),则在本地 SQL Express 实例 (.\SQLEXPRESS) 上创建数据库。如果未安装 SQL Express,则 Code First 将尝试使用 LocalDb ((localdb )\v11.0) - LocalDb 包含在 Visual Studio 2012 中"

更多信息:http://msdn.microsoft.com/en-us/data/jj591621.aspx

关于entity-framework - Entity Framework 代码优先默认数据库位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15543474/

相关文章:

linq - 是否可以从 Visual Studio 2008 中的 edmx 更新 sql 数据库架构?

visual-studio-2012 - 无法解析远程名称 'www.nuget.org'

C# 无法使用服务引用生成基于任务的操作

c++ - 传递指向变量的指针或指向变量的指针的地址会导致相同的行为

windows-8 - Expression Blend 中的 "star"测量值是什么?

visual-studio - 我可以在多显示器配置上使用 Visual Studio 2012 吗?

c# - 当转换为父类时查找 TypeOf Child 类

c# - Entity Framework 代码迁移 : Exception has been thrown by the target of an invocation

c# - 将 SQL 2012 FORMAT 函数与 LINQ to Entity Framework 结合使用

c# - 使用 LINQ 对分层数据进行分组