Search code examples
c#databaseunity-container

Entity Framework Code First can't find database in server explorer


So I was following this introduction to the Entity Framework Code First to create a new database ( https://msdn.microsoft.com/en-us/data/jj193542 ) and I followed the example completely. Now I want to add it to my server explorer in Visual Studio 2013.

Tried both LocalDb ((localdb)\v11.0) or SQL Express (.\SQLEXPRESS) but the database doesn't show, I know it's working because I've tested it multiple times now and it keeps appending and fetching data from the database, so where would it be residing?

Besides the default Visual Studio 2013 I have an SQL Server setup. Thanks

config

<configuration> 
  <configSections> 
    <!-- For more information on Entity Framework configuration, visit go.microsoft.com/fwlink/… --> 
    <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>

Solution

  • Looking at your config (supplied during chat) I can see that your EF is using localdb and MSSQLLocalDB instance. Try:

    (localdb)\MSSQLLocalDB