public void save() { try { using (Repositories.UserRepository accs = new Repositories.UserRepository()) { Console.WriteLine("Saving Player"); Console.WriteLine(JsonConvert.SerializeObject(entity.items)); foreach (Models.ItemEF item in entity.items) { item.mustSave = false; if (item.id == 0) { accs.Entry(item).State = System.Data.Entity.EntityState.Added; } else { accs.Entry(item).State = System.Data.Entity.EntityState.Modified; //Forces it to update } } //if (mustAttach) accs.users.Attach(this); //adds new items accs.Entry(entity).State = System.Data.Entity.EntityState.Modified; accs.Entry(this).State = System.Data.Entity.EntityState.Modified; accs.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }