public void AddOrUpdateSetting(string key, string value)
 {
     using (var context = GetContext())
     {
         var setting = context.Settings.FirstOrDefault(p => p.Key == key);
         if (setting == null)
         {
             setting = new Settings()
             {
                 Id = DbIdHelper.GetNextID(),
                 Key = key,
                 Value = value
             };
             context.Settings.AddObject(setting);
         }
         else
         {
             setting.Value = value;
         }
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Create a new Settings object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="key">Initial value of the Key property.</param>
 /// <param name="value">Initial value of the Value property.</param>
 public static Settings CreateSettings(global::System.Int64 id, global::System.String key, global::System.String value)
 {
     Settings settings = new Settings();
     settings.Id = id;
     settings.Key = key;
     settings.Value = value;
     return settings;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Settings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSettings(Settings settings)
 {
     base.AddObject("Settings", settings);
 }