There's a very strange thing happening when I debug in Visual Studio.
I have a local database defined thus in Web.config...
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\cms_test_data;Initial Catalog=cms_test_data;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
When I debug the project the DbSet objects are empty. For example Pages (see below) returns a Count of 0 at a breakpoint in a Page controller action.
But when I examine the tables in Server Explorer they are populated with the test data.
Here is how my DB Context is defined...
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<Page> Pages { get; set; }
...
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
...
}
Even more strangely, when I use an external database this all works.
Any ideas? Thanks.