private static void CreateNewEntryInDB() { var db = new BlogDB(); var post = new Posts() { Title = "New Title", Body = "New Post Body", Date = DateTime.Now }; db.Posts.Add(post); db.SaveChanges(); }
private static void CascadingInsert() { var db = new BlogDB(); var post = new Posts() { Title = "New Post Title", Date = DateTime.Now, Body = "This post have comments and tags", Users = db.Users.First(), Comments = new Comments[] { new Comments() { Text = "Comment 1", Date=DateTime.Now }, new Comments() { Text = "Comment 2", Date=DateTime.Now, Users = db.Users.First()} }, Tags = db.Tags.Take(3).ToList() }; db.Posts.Add(post); db.SaveChanges(); }