private static void AddLensToManufacturer(PhotographySystemEntities context, Manufacturer manufacturer, Lens lense)
 {
     if (manufacturer != null)
     {
         if (manufacturer.Lenses.Contains(lense))
         {
             Console.WriteLine("Existing lens: {0}", lense.Model);
         }
         else
         {
             manufacturer.Lenses.Add(lense);
             context.SaveChanges();
             Console.WriteLine("Created lens: {0}", lense.Model);
         }
     }
 }
        private static Manufacturer CreateNewManufacturerIfNotExists(PhotographySystemEntities context, XElement xManufacturer)
        {
            Manufacturer manufacturer = null;
            var xManufacturerName = xManufacturer.Element("manufacturer-name");
            if (xManufacturerName != null)
            {
                string manufacturerName = xManufacturerName.Value;
                manufacturer = context.Manufacturers.FirstOrDefault(m => m.Name == manufacturerName);
                if (manufacturer != null)
                {
                    Console.WriteLine("Existing manufacturer: {0}", manufacturerName);
                }
                else
                {
                    manufacturer = new Manufacturer(){ Name = manufacturerName};
                    context.Manufacturers.Add(manufacturer);
                    context.SaveChanges();
                    Console.WriteLine("Created manufacturer: {0}", manufacturerName);
                }
            }

            return manufacturer;
        }