active92 active92 - 9 months ago 55
SQL Question

Unable to find database in SQL Server Management Studio

I'm currently following Entity Framework Tutorial. The code manage to run successfully. I am also able to retrieve the data.

However, I could not find my database in

SQL Server Management Studio

This is my connection string

<add name="MyContextDB" connectionString="data source=.\SQLEXPRESS;Initial Catalog=EFMyContextDB;integrated security=True;user instance=True;multipleactiveresultsets=True;" providerName="System.Data.SqlClient" />

This is my DbContext

public class MyContext : DbContext
public MyContext() : base("name = MyContextDB") { }
public virtual DbSet<Course> Courses { get; set; }
public virtual DbSet<Enrollment> Enrollments { get; set; }
public virtual DbSet<Student> Students { get; set; }

Answer Source

If you are using user instance=True; the database will only exist under your currently logged in users context. Im not too sure what impact this has in SSMS but it may be that you need to be logged in as that user to SSMS also

More info here: