5

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?

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
Bgl86
  • 727
  • 8
  • 20

1 Answers1

15

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"/>
Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
  • 1
    Thank you. But my master database does not contain any tables. – Bgl86 Mar 14 '16 at 08:43
  • 1
    @Bgl86...you have to specify the database you want the connection string to connect to so you just need to specify the `Initial catalog` in your connection string and try again. – Salah Akbari Mar 14 '16 at 08:44
  • 1
    I just try to understand what was going on ;) Though there are 3 temp tables in master tempdb, I guess it was going there. I have added Initial Catalog but now I get an exception "The provider did not return a ProviderManifestToken string" But thanks I will have a look whats the problem :) – Bgl86 Mar 14 '16 at 08:48