实体框架代码第一个默认数据库位置 [英] Entity Framework Code First Default Database Location

查看:115
本文介绍了实体框架代码第一个默认数据库位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to follow the video tutorial on http://msdn.microsoft.com/en-us/data/jj193542 using Visual Studio 2012 Express for Desktop.

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

I created POCO's, and a DbContext, ran some sample queries and it worked. But I did not provide any connection string. So where is the database? (sdf or mdf file maybe?)

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

During the tutorial the guy uses SQL Server Object Explorer to view the database, but I couldn't find that view in VS Express.

为了参考,这里是生成的默认App.config。

For reference, here is the default App.config that gets generated.

<?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实例(.\QQLEXPRESS)上创建数据库,如果未安装SQL Express,则Code First将尝试使用LocalDb((localdb)\v11.0) - LocalDb包含在Visual Studio 2012

"If SQL Express is installed (included in Visual Studio 2010) then the database is created on your local SQL Express instance (.\SQLEXPRESS). If SQL Express is not installed then Code First will try and use LocalDb ((localdb)\v11.0) - LocalDb is included with Visual Studio 2012"

有关详细信息: http: //msdn.microsoft.com/en-us/data/jj591621.aspx

这篇关于实体框架代码第一个默认数据库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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