Entity Framework Code First Default Database Location

entity-framework visual-studio-2012

Question

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>
1
3
3/21/2013 9:19:50 AM

Accepted Answer

"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

8
3/21/2013 1:19:37 PM

Popular Answer

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



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow