Created a model class:

public class MainModel { MagnesiumEntites _context; public Mainmodel() { _context = new MagnesiumEntites(); _Parts = new ObservableCollection<Part>(_context.part); } private ObservableCollection<Part> _Parts; public ObservableCollection<Part> Parts { get { return _Parts; } set { value = _Parts; } } } 

And tied to the DataGrid Parts collection. How can I save changes to the database immediately when changing in the table?

    1 answer 1

    The ObservableCollection has a CollectionChanged event.

    In the event handler, call _context.SaveChanges()