static void DeleteModel(int modelId) { using (var db = new BikeStoreEntities()) { var model = new Model { ModelId = modelId }; db.Models.Attach(model); db.Models.Remove(model); db.SaveChanges(); } }
static int CreateModel() { int modelId = 0; using (var db = new BikeStoreEntities()) { var model = new Model { Name = "Domane 5.2", ListPrice = 3499.99m }; db.Models.Add(model); db.SaveChanges(); modelId = model.ModelId; } Console.WriteLine("New Model: " + modelId); return modelId; }