Code-First approach, location of database and all instances (v110, etc)

12,754

The physical master database files are at

C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0  

The DB files are simply in C:\Users\<user>

You can also connect to localdb using SSMS by using server (localdb)\v11.0 and delete the database from there.

The official documentation is here http://msdn.microsoft.com/en-AU/library/hh510202.aspx

Edit by QuantumHive:
I finally figured out that the Database can be found in the instance called MSSqlLocalDb which Entity Framework added by default in my App.config. I now have a visualization of the database in Visual Studio:
enter image description here
I'm guessing those tutorials are old and referring to the v11.0 instance, which perhaps and older version of EF added that by default at the time.

Share:
12,754
QuantumHive
Author by

QuantumHive

Updated on July 07, 2022

Comments

  • QuantumHive
    QuantumHive almost 2 years

    I'm following this tutorial to create a Code-First Database.
    After installing EF and creating those first basic classes it says:

    Run your application and you will see that a MigrationsCodeDemo.BlogContext database is created for you.

    Well, I have VS2013 Pro with all the SQL Servers installed (full installation of VS2013 Pro).
    Now as you can see from the image below, I can't find my database after running the program as the tutorial is suggesting. When I try to do the migrations part of the tutorial, I indeed get the error it supposed to get, implying that somewhere the database actually has been created. I just am not able to find it.
    Where is it located?
    enter image description here
    Edit: added 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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="mssqllocaldb" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>
    
  • QuantumHive
    QuantumHive over 9 years
    OMG! Found it! It was indeed in C:\Users\<user>. I was searching the entire internet for this small answer. Where is the official documentation for this sneaky little thing?
  • QuantumHive
    QuantumHive over 9 years
    Also what bothers me so much is that looking at all those MSDN walkthroughs they all say that you have to connect with either localdb or sqlexpress depending on which is installed, like here: msdn.microsoft.com/en-us/data/jj193542.aspx The annoying thing is, they don't tell you these basic things. Which led me some frustrating hours of searching. Thanks, I love you Pratik! <3
  • QuantumHive
    QuantumHive over 9 years
    I'm also wondering, why isn't the database added to SQL Server Object Explorer as the tutorials all are suggesting?
  • Kioshiki
    Kioshiki almost 9 years
    the questions already been answered but I just had this issue recently too. There's a reason it's different. the v11.0 part is SQL Server 2012 while mysqllocaldb is SQL Server 2014 (Source: msdn.microsoft.com/en-us/library/…)