private static void PrintAirlineCount() { using (var ctx = new AirTravelContext()) { Console.WriteLine("Airline Count: {0}", ctx.Airlines.Count()); } }
private static void RemoveData() { using (var ctx = new AirTravelContext()) { ctx.Database.ExecuteSqlCommand("DELETE FROM Aircraft"); ctx.Database.ExecuteSqlCommand("DELETE FROM Airlines"); } }
private static void PrintAirlinesAndAircraft() { using (var ctx = new AirTravelContext()) { foreach (var airline in ctx.Airlines.Include(a => a.Aircraft)) { Console.WriteLine("{0}: {1}", airline.Code, string.Join(", ", airline.Aircraft.Select(a => a.EquipmentCode))); } } }
private static void Seed() { using (var ctx = new AirTravelContext()) { ctx.Airlines.Add( new Airline { Code = "UA", Name = "United Airlines", Aircraft = new List <Aircraft> { new Aircraft { EquipmentCode = "788" }, new Aircraft { EquipmentCode = "763" } } }); ctx.Airlines.Add( new Airline { Code = "FR", Name = "Ryan Air", Aircraft = new List <Aircraft> { new Aircraft { EquipmentCode = "738" }, } }); ctx.SaveChanges(); } }