//Disposing the context before close the form private void YourForm_FormClosing(object sender, FormClosingEventArgs e) { context.Dispose(); }