Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 939
QuantumHive Avatar asked Sep 02 '14 22:09

QuantumHive


Video Answer


1 Answers

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.

like image 115
softveda Avatar answered Sep 20 '22 20:09

softveda