C# .NET - MVC Database not using one in App_Data folder
Asked By Pete Smith on 19-May-12 10:32 AM

I have created an mdf database in the app_data folder.
I have added a DB context file and a model that matches the table in the database.
The only connection string is set to reference this database in the app_data folder.
When i run my project it runs fine, will add and delete data ok but the datbase in the app_data folder is not being changed and the table is empty.
it is creting a new sqlserver express database outside of my project and not using the one in the app_data folder.
How do i specify that i want this database to be used rather than creating another one elsewhere
Connection string is:
add name="myDB" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|App_Data|myDB.mdf;User Instance=true" providerName="System.Data.EntityClient"
Context file is:
public class myDBContext : DbContext
{
public DbSet ContentPages { get; set; }
}
Model is
[Table("ContentPages", Schema = "dbo")]
public class ContentPage
{
public int Id {get; set;}
etc. etc.
}