public static void Init() { using (var context = new AppDbContext()) { if (!context.Posts.Any()) { context.Posts.Add(new Post{PostDate=DateTime.Parse("6/1/2015"), Title = "New Tech Roundup", Body = "", Comments = {new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}}}); context.Posts.Add(new Post{PostDate=DateTime.Parse("6/2/2015"), Title = "Hipsters, and how to spot them", Body = "", Comments = {new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}}}); context.Posts.Add(new Post{PostDate=DateTime.Parse("6/3/2015"), Title = "Bug or feature?", Body = "", Comments = {new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}}}); context.Posts.Add(new Post{PostDate=DateTime.Parse("6/4/2015"), Title = "Hot Tech Features", Body = "", Comments = {new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}, new Comment{Email = "*****@*****.**"}}}); context.SaveChanges(); } } }