Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant find my EF code first database

I am doing Microsoft's MVC getting started tutorial:

Getting Started with Entity Framework 6 Code First using MVC 5.

This includes the creation of a code first database.

It all works fine, but I am not able to find my database.

This is my ConnectionString:

<add name="MovieDBContext" connectionString="Data Source=.\SQLEXPRESS; Integrated Security=True" providerName="System.Data.SqlClient"/>

If I debug my index Method the connection is as follow:

Data Source=.\SQLEXPRESS; Integrated Security=True

But there is no Database in my SQLEXPRESS Instance, I have checked it with SQL Server Management Studio.

I also cant find anything if I search my filesystem for *.mdf.

App_Data in my Project is Empty...

But all CRUD operations are working fine, there has to be something.

The only way I can see that table is to connect to .\SQLEXPRESS via the Visual Studio Server Explorer. But where is this physically located? Why cant I see the table if I connect to .\SQLEXPRESS via SQL Server Management Studio?

Any idea?

like image 383
Bgl86 Avatar asked Mar 14 '16 08:03

Bgl86


1 Answers

You didn't specify the Initial Catalog in your connection string so probably you are using the Master database.

You need to specify the Initial catalog like this:

<add name="MovieDBContext" 
     connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=yourDBName;Integrated Security=True" 
     providerName="System.Data.SqlClient"/>
like image 51
Salah Akbari Avatar answered Nov 08 '22 02:11

Salah Akbari