public void CreatePeople() { using (var context = new EF6RecipesContext()) { var person = new Person { FirstName = "Robert", MiddleName = "Allen", LastName = "Doe", PhoneNumber = "867-5309" }; context.People.Add(person); person = new Person { FirstName = "Billy", MiddleName = "Albert", LastName = "Minor", PhoneNumber = "907-2212" }; context.People.Add(person); person = new Person { FirstName = "Kathy", MiddleName = "Anne", LastName = "Ryan", PhoneNumber = "722-0038" }; context.People.Add(person); context.SaveChanges(); } }
public void GetPeople() { using (var context = new EF6RecipesContext()) { foreach (var person in context.People) { Console.WriteLine("{0} {1} {2}, Phone: {3}", person.FirstName, person.MiddleName, person.LastName, person.PhoneNumber); } } }
private static void Scenariu2() { using (var context = new EF6RecipesContext()) { var product = new Product { SKU = 147, Description = "Expandable Hydration Pack", Price = 19.97M, ImageURL = "/pack147.jpg" }; context.Products.Add(product); product = new Product { SKU = 178, Description = "Rugged Ranger Duffel Bag", Price = 39.97M, ImageURL = "/pack178.jpg" }; context.Products.Add(product); product = new Product { SKU = 186, Description = "Range Field Pack", Price = 98.97M, ImageURL = "/noimage.jp" }; context.Products.Add(product); product = new Product { SKU = 202, Description = "Small Deployment Back Pack", Price = 29.97M, ImageURL = "/pack202.jpg" }; context.Products.Add(product); context.SaveChanges(); } using (var context = new EF6RecipesContext()) { foreach (var p in context.Products) { Console.WriteLine("{0} {1} {2} {3}", p.SKU, p.Description, p.Price.ToString("C"), p.ImageURL); } } }