public class ProductDbContextInitializer : DropCreateDatabaseAlways<ProductDbContext>
protected override void Seed(ProductDbContext context)
Category[] categories = new Category[]
new Category { CategoryID = 1, CategoryName = "Food", Description = "Edible stuff",
Products = new Product[] {
new Product { ProductID = 1, ProductName = "Candy", UnitPrice = 10},
new Product { ProductID = 2, ProductName = "Fruits", UnitPrice = 20, Discontinued = true },
new Product { ProductID = 5, ProductName = "Cereal", UnitPrice = 10},
new Category { CategoryID = 2, CategoryName = "Clothes", Description = "Personal stuff",
Products = new Product[] {
new Product { ProductID = 3, ProductName = "Shirt", UnitPrice = 50},
new Product { ProductID = 4, ProductName = "Cap", UnitPrice = 15},
new Category { CategoryID = 3, CategoryName = "Furniture", Description = "Household stuff",
Products = new Product[] {
new Product { ProductID = 6, ProductName = "Table", UnitPrice = 100},
new Product { ProductID = 7, ProductName = "Chair", UnitPrice = 60},
new Product { ProductID = 8, ProductName = "Lamp", UnitPrice = 20, Discontinued = true },
foreach (var category in categories)
context.Categories.Add(category);
So each Product in our data model belongs to a Category. The ProductDbContext is a [DbContext](https://msdn.microsoft.com/en-us/library/Gg679505) type that has a [DbSet](http://go.microsoft.com/fwlink/?linkid=230808) of type Product and a [DbSet](http://go.microsoft.com/fwlink/?linkid=230808) of type Category. The [DbSet](http://go.microsoft.com/fwlink/?linkid=230808) tells Entity Framework that Product and Category are entity types. It also uses the current value of the [HttpContext](https://msdn.microsoft.com/en-us/library/x08ey989) to distinguish between the Runtime and Design time contexts.