I am doing a tutorial for ASP.NET MVC3 repository and instead of connecting to a connected database, EF creates a new database in SQLEXPRESS (code first). How to prevent this. With the configuration I'm using EF, I need to connect to an existing database, not create a new one. I have a DbContext class as shown below
using System.Data.Entity;
namespace MusicStore.Models
{
public class MusicStoreEntities:DbContext
{
public DbSet<Album> Albums { get; set; }
public DbSet<Genre> Genres { get; set; }
}
}
And my web.config has the following connection string
<connectionStrings>
<add name="MusicStoreEntities"
connectionString="data source=.\SQLEXPRESS; Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|\MvcMusicStore.mdf; User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
source
share