title: Delete row in DataGridView and database
body: <p>I'm completely new to databases and EF but I made a database with EF and have a DataGridView control on a windows form that I made by dragging my datasource to my form.  After the user enters their information and hits the save button it succesfully saves their information in the database using this code</p>
  
  <pre><code>public partial class bsMainPage : Form
  {
      BSDATAContainer db = new BSDATAContainer();
      public bsMainPage()
      {
          InitializeComponent();
      }
  
      private void saveBtn_Click(object sender, EventArgs e)
      {
          BSRecords breakfastRecord = new BSRecords();
          breakfastRecord.BS = brkBS.ToString();
          breakfastRecord.Carbs = brkCarb.ToString();
          breakfastRecord.Notes = brkftNoteTxt.Text;
          breakfastRecord.Date = dateTxt.Text;
          BSRecords lunchRecord = new BSRecords();
          lunchRecord.BS = lchBS.ToString();
          lunchRecord.Carbs = lchCarb.ToString();
          lunchRecord.Notes = lnchNoteTxt.Text;
          lunchRecord.Date = dateTxt.Text;
          BSRecords dinnerRecord = new BSRecords();
          dinnerRecord.BS = dnrBS.ToString();
          dinnerRecord.Carbs = dnrCarb.ToString();
          dinnerRecord.Notes = dnnrNoteTxt.Text;
          dinnerRecord.Date = dateTxt.Text;
          db.BSRecords.Add(breakfastRecord);
          db.BSRecords.Add(lunchRecord);
          db.BSRecords.Add(dinnerRecord);
          db.SaveChanges();
     }
  }
  </code></pre>
  
  <p>But it doesn't show up in the database until I restart the program.  When the user selects a row in the DataGridView and hits the delete button which has this code</p>
  
  <pre><code>private void deleteRowsBtn_Click(object sender, EventArgs e)
  {
      foreach (DataGridViewRow item in this.bSRecordsDataGridView.SelectedRows)
      {
          bSRecordsDataGridView.Rows.RemoveAt(item.Index);
      }
      db.SaveChanges();
  }
  </code></pre>
  
  <p>It deletes the data in the DataGridView but doesn't save the changes in my database.  I have followed all the answers I found on here and other sites to delete in the database but nothing will save the deleted changes.  Does anyone have any idea how to make it work?</p>