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

c# entity-framework localdb sql-server visual-studio


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"?>
    <!-- For more information on Entity Framework configuration, visit -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameter value="mssqllocaldb" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
9/3/2014 2:56:42 PM

Accepted Answer

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

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.

9/3/2014 3:14:59 PM

Popular Answer

You are connected to localDb\Projects instance and not to localDb\v11.0, the only thing you need to do is clicking 'Add Sql Server' and paste '(localDb)\v11.0' into Server name, then connect and you are done.

Related Questions


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