Bahadır Yağan
Bahadır Yağan

Reputation: 5967

Entity Framework Code First Default Database Location

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

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?)

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

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>

Upvotes: 3

Views: 7413

Answers (2)

Daniel de Zwaan
Daniel de Zwaan

Reputation: 3105

@Default is correct, the default SQL server is (LocalDb)\mssqllocaldb in VS 2015 and 2017.

Upvotes: 0

chicco
chicco

Reputation: 147

"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"

For more information : http://msdn.microsoft.com/en-us/data/jj591621.aspx

Upvotes: 8

Related Questions