Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 256
RandomPerson Avatar asked Jun 04 '15 22:06

RandomPerson


People also ask

How do I import data from a database into Entity Framework?

Select Data from the left menu and then ADO.NET Entity Data Model Select the connection to the database you created in the first section and click Next Click the checkbox next to Tables to import all tables and click Finish

Does Entity Framework Core Data Access Support localdb?

I created a new UWP App with a UWP Class library to hold an Entity Framework Core Data Access layer. LocalDB is not supported on this platform. Back in my original program I have discovered that create database behaviour of the UWP app is different when running in release mode to running in debug mode.

How to create an Entity Framework data model in Visual Studio?

We will use the Entity Framework Tools for Visual Studio to help us generate some initial code to map to the database. These tools are just generating code that you could also type by hand if you prefer. Project -> Add New Item… Select Data from the left menu and then ADO.NET Entity Data Model

Can code first create an empty database?

This scenario includes targeting a database that doesn’t exist and Code First will create, or an empty database that Code First will add new tables to. Code First allows you to define your model using C# or VB.Net classes.


1 Answers

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

(localdb)\MSSQLLocalDB
like image 105
KrishnaDhungana Avatar answered Oct 30 '22 16:10

KrishnaDhungana