private static void InsertNewCustomersToDb() { var newCustomer = new Customer { CustomerID = "AAAAA", CompanyName = "Lethal Corporation", ContactName = "Alfonso Salvarez", ContactTitle = "CEO", Address = "33 Pedro Almodovar Sq.", City = "Ciudad Real", PostalCode = "11223", Country = "Spain", Phone = "030-0023002", Fax = "030-0023003" }; db.Customers.Add(newCustomer); affectedRows = db.SaveChanges(); Console.WriteLine("({0} row(s) affected)", affectedRows); }
private static string InsertNewCustomer() { using (var db = new NorthwindEntities()) { var newCustomer = new Customer() { CustomerID = "ABC", CompanyName = "Telerik", ContactName = "John Doe", ContactTitle = "Owner", Address = "Al. Malinov Str. 31", City = "Sofia", PostalCode = "1784", Country = "Bulgaria", Phone = "(359) 888888888" }; db.Customers.Add(newCustomer); db.SaveChanges(); return newCustomer.CustomerID; } }