/// <summary> /// Load ListBox with CompanyName and primary key used for returning /// customer by primary key to demonstrate using .Include /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Form1_Shown(object sender, EventArgs e) { var waitForm = new ConnectStatusForm() { Top = Top, Left = Left, TopMost = true }; await Task.Delay(20); waitForm.Show(); await Task.Delay(10); using (var context = new NorthwindContext()) { // set to true for logging Entity Framework operations // for this instance of the DbContext. // context.Diagnostics = true; try { if (await context.Database.CanConnectAsync()) { var results = await context.CustomerDisplay(); CustomerListBox.DataSource = results; IncludeStatementsConventionalButton.Enabled = true; IncludeStatementsUsingExtensionButton.Enabled = true; } else { waitForm.Close(); MessageBox.Show("Failed to connection to server, please check the connection string."); } } catch (Exception ex) { waitForm.Close(); MessageBox.Show(ex.Message); } finally { waitForm.Dispose(); } } }