Github Copliot Github Copliot

Add a Delete Button to Coffee Tracker Page with GitHub Copilot

Automatically generate, insert, and test a fully functional delete button that removes a coffee entry from the SQLite database and updates the UI, all with minimal manual coding.

Takes
Code Text
Produces
Code
What you'll produce
Input
Add a Delete button to the coffee edit page that removes the coffee entry from the SQLite DB and updates the UI list.
Output
csharp // UI markup // ViewModel method public async Task DeleteCoffeeAsync() { if (SelectedCoffee == null) return; _dbContext.Coffees.Remove(SelectedCoffee); await _dbContext.SaveChangesAsync(); Coffees.Remove(SelectedCoffee); SelectedCoffee = null; }

The Workflow

8 steps · click a step number to mark it done

Open Github Copliot and have it ready before you start

Open the Coffee Tracker solution in Visual Studio 2022 and navigate to the EditCoffee.xaml (or .cshtml) file where the coffee details are displayed.

Click the GitHub Copilot button in the toolbar to open the Copilot Chat pane.

In the Copilot Chat, type: "Create a new edit thread to add a Delete button that removes the current coffee record from the SQLite database and refreshes the list view" and press Enter.

Review the suggested code block that adds a Button element to the UI and inserts a method called DeleteCoffeeAsync with proper async/await handling.

Click Accept to insert the suggested UI markup and method implementation into the file.

If Copilot asks for additional context (e.g., the DbContext name), provide it by typing the name (e.g., "CoffeeDbContext") and let Copilot finish the method.

Run the project (F5), navigate to a coffee item, click the new Delete button, and verify that the entry is removed from the database and the list updates.

Open the Copilot Chat again and ask: "Generate a unit test for DeleteCoffeeAsync that confirms the coffee record is removed". Accept the generated test and add it to your test project.

Did this workflow help?
🔍 Looking for AI tools? Try searching!