Reputation: 89
I am creating a Code First Entity Framework to create a database to where I point it to. I have an instance of SQL => DESKTOP-98TG6JE\SQLEXPRESS
and another one => DESKTOP-98TG6JE
In my Asp MVC code, my connection string is like so in the Web.config
<connectionStrings>
<add name="MusicStoreDB" connectionString="Data Source=DESKTOP-98TG6JE;Initial Catalog=MusicStoreDB;User ID=sa;Password=myPassword123" providerName="System.Data.SqlClient" />
</connectionStrings>
and in my MusicStoreDB : DbContext
,
public MusicStoreDB() : base("MusicStoreDB")
{
}
But when I run the program, it creates a database in the DESKTOP-98TG6JE\SQLEXPRESS
named DefaultConnection
and on the instance where I want to create the database, no MusicStoreDB
database is created.
Image of the created database on the wrong instance
Can you please explain it to me why this is happening? Thank you.
Upvotes: 0
Views: 48
Reputation: 5321
Check you connection string name provided in ApplicationDbContext
:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext() : base("MusicStoreDB")
{
}
}
Upvotes: 1