I'm creating an ASP.NET MVC web application. I've installed the Entity Framework. I have done the following model:
public class EmploymentHistory
{
public Guid Id { get; set; }
public Guid UserId { get; set; }
public int DateFromMonth { get; set; }
public int DateFromYear { get; set; }
public int DateToMonth { get; set; }
public int DateToYear { get; set; }
public string CompanyName { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public string County { get; set; }
[DisplayName("I was unemployed during this time")]
public bool IsUnemployed { get; set; }
}
I have created the following DbContext class:
public class EmploymentDbContext : DbContext
{
public DbSet<EmploymentHistory> EmploymentsHistory { get; set; }
}
And the connection string in my Web.config file looks like that:
<connectionStrings>
<add name="EmploymentDbContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=EmploymentsHistory;Integrated Security=False" providerName="System.Data.SqlClient"/>
</connectionStrings>
When I run the project, I can see the database EmploymentsHistory in the Server Explorer in Visual Studio but when I expand it and then expand its Tables, I can't see the EmploymentHistory table which I'm supposed to see.
AttachDbFileNamepath. It's always the same trouble with these localdb's. No doubt you're looking at the wrong database file.