public void UpdateEngines(string[] names, CancellationToken token)
 {
     using (DatabaseContext context = GetContext())
     {
         int i = 0;
         foreach (string name in names)
         {
             Console.WriteLine("Check engine {0}", name);
             if (token.IsCancellationRequested) break;
             // exists?
             if (!context.Engines.Any(o => o.Name == name))
             {
                 Engine e = new Engine()
                 {
                     Name = name
                 };
                 context.AddToEngines(e);
                 Console.WriteLine("Added engine {0}", name);
                 i++;
             }
         }
         if (i > 0) context.SaveChanges();
     }
 }
 /// <summary>
 /// Create a new Engine object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Engine CreateEngine(global::System.Int64 id, global::System.String name)
 {
     Engine engine = new Engine();
     engine.Id = id;
     engine.Name = name;
     return engine;
 }
        public void SyncEngines(SearchEngine[] engines, CancellationToken token)
        {
            using (DatabaseContext context = GetContext())
            {
                int i = 0;
                foreach (SearchEngine engine in engines)
                {
                    if (token.IsCancellationRequested) break;
                    Console.WriteLine("Check engine {0}", engine.Name);

                    // check existence
                    if (context.Engines.Any(o => o.Name == engine.Name))
                    {
                        // exists - update ID
                        engine.Id = context.Engines.First(o => o.Name == engine.Name).Id;
                        Console.WriteLine("Engine {0} ({1}) already exists", engine.Name, engine.Id);
                    }
                    else
                    {
                        // does not exist - insert
                        Engine e = new Engine()
                        {
                            Name = engine.Name
                        };
                        context.AddToEngines(e);
                        Console.WriteLine("Added engine {0}", engine.Name);
                        i++;
                    }

                }
                if (i > 0) context.SaveChanges();
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Engines EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEngines(Engine engine)
 {
     base.AddObject("Engines", engine);
 }