2013-03-21 84 views
3

我正在嘗試使用Visual Studio 2012 Express for Desktop關注http://msdn.microsoft.com/en-us/data/jj193542上的視頻教程。實體框架代碼第一個默認數據庫位置

我創建了POCO's和一個DbContext,運行了一些示例查詢並且工作。但是我沒有提供任何連接字符串。那麼數據庫在哪裏? (sdf或mdf文件可能?)

在教程期間,使用SQL Server對象資源管理器查看數據庫,但在VS Express中找不到該視圖。

作爲參考,這裏是生成的默認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> 

回答

8

「如果安裝了SQL Express(包含在Visual Studio 2010)則數據庫會在您的本地SQL Express實例創建(。\ SQLEXPRESS)。如果未安裝的SQL Express,然後代碼首先會嘗試使用的LocalDB((的LocalDB)\ V11.0) - 的LocalDB附帶的Visual Studio 2012"

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

+1

對於Visual Studio 20 15它似乎默認爲'(LocalDb)\ mssqllocaldb'。 – Default 2016-10-28 15:22:21

0

@default是正確的,默認的SQL服務器是在2015年VS 2017和

(LocalDb)\mssqllocaldb
相關問題