Abhilash V
Abhilash V

Reputation: 329

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

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

DbContext

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

Upvotes: 2

Views: 631

Answers (1)

Sampath
Sampath

Reputation: 65958

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"/>

Upvotes: 2

Related Questions