void refreshDataInDatagrid() { using (var context = new DC_DatabaseEntities()) { var persons = context.PersonTables.ToList(); EF_Data = new ObservableCollection<PersonModel>(persons.Select(x => new PersonModel { name = x.Name })); } }
private void AddPerson(addPersonToEFWindow obj) { try { using (var context = new DC_DatabaseEntities()) { context.PersonTables.Add(new PersonTable { Name = this.name }); context.SaveChanges(); } _efViewModel.EF_Data.Add(new PersonModel { name = this.name }); obj.Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }