我正在尝试关注 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 中"
关于entity-framework - Entity Framework 代码优先默认数据库位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15543474/