Abhilash V Abhilash V - 1 year ago 89
SQL Question

Database created from Code first shows in Server Explorer and not in SQL Server Object Explorer

Database 'EFCheck' (Created by Entity Framework code first) is showing in Server Explorer and not in SQL Server Object Explorer and I'm not seeing the created database in my SQL Server. Can anyone tell me where I can see the new db in SQL Server ?

Server Explorer where I see the new EFCheck db created by EF

SQL Server Object Explorer where I don't see the EFCheck db

My connection string in Web.Config

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


public class Db : DbContext {
public Db() : base("name=Db") { }
public virtual DbSet<Blog> Blogs { get; set; }
public virtual DbSet<Post> Posts { get; set; }

Answer Source

You didn't specify the Initial Catalog in your connection string.You have to set the Initial catalog as shown below.

<add name="Db" 
connectionString="Data Source=ABHI\SQLEXPRESS;
Initial Catalog=Your-Db-Name-Should-Be-Set-Here;
Integrated Security=True" providerName="System.Data.SqlClient"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download