Hi I am using Entity framework code first for the first time and I am having trouble generating the tables.I have created an empty database in my App_Data in an MVC3 application. This are the models I have created:
public class Brand {
public int BrandId { get;set; }
public string BrandName { get;set; }
}
public class Model
{
public int ModelId { get;set; }
public Brand BrandId { get;set; }
public Category CategoryId { get;set; }
public string ModelName { get;set; }
}
public class Category
{
public int CategoryId { get;set; }
public string CategoryName { get;set; }
}
This is the dbContext:
public class CarsEntities : DbContext{
public DbSet<Brand> Brands { get;set; }
public DbSet<Model> Models { get;set; }
public DbSet<Category> Categories {get;set;}
}
And this is the connectionString in web.config:
<connectionStrings>
<add name="CarsEntities" connectionString="Data Source='D:\Projects IDE\Visual Studio\MyWork\Websites\SellCars\SellCars\App_Data\Cars.sdf'" providerName="System.Data.SqlClient" />
</connectionStrings>
Now I have initialized CarsEntities in my HomeController but it seems that none of the tables get generated.What am I doing wrong?