Building reliable C# API applications can be complex, especially when integrating backend systems and automating repetitive tasks. In this post, I’ll demonstrate how GitHub Copilot Agent Chat, powered by a Pro Subscription—utilizing premium models like Claude 4.0—can deliver faster, cleaner, and more automated results than free AI coding solutions.
1. Project Overview: Why Use Premium Copilot Agent?
Free AI models in Copilot offer basic assistance but often require extensive manual intervention.
Premium models like Claude 4.0 promise more robust code, better error handling, and smoother backend integration. I saw this firsthand while running the same prompt multiple times using both ChatGPT 4.1 and Claude 4.
The demo focuses on building a C# API app that manages a deck of playing cards, including a SQL Server backend for state management.
2. Setup: Configuring Copilot Agent for Success
Visual Studio Code: Start with a vanilla VS Code install. Install C# and Copilot extensions.
To streamline demos and the agent process, look at adjusting these settings in VS Code under Chat. Copilot Agent Settings:
– Increase “max requests in Agent mode” to 250 for uninterrupted agent execution.
– Set “auto-accept delay” to 15 seconds to streamline file updates during new app builds.
– Enable “tool auto-approve” for automated terminal commands (use cautiously in isolated projects).
3. Prompt Engineering & Model Selection
Craft a detailed prompt outlining project requirements, API endpoints, data models, and test coverage.
Premium models (Claude 4.0) interpret complex prompts more reliably than free models (ChatGPT 4.1), again, when running prompts side by side.
4. Build & Automation: Running the Agent
Copilot Agent handles all code and backend file generation.
Observe minimal manual interaction: premium models handle SQL table creation, API layer implementation, and even error correction automatically.
Free models often require approvals or miss backend automation steps.
5. Testing: Postman Integration and Output Quality
Import the Postman collection generated by Copilot Agent.
Run API requests and observe rich, detailed outputs—deck ID, card counts, and timestamps.
Unit tests embedded in Postman scripts provide an extra layer of verification.
6. Key Differences: Free vs. Premium Models
Output quality: Premium models deliver cleaner, more robust, and production-ready code.
Testing: Automated test cases and richer API responses are standard with Claude 4.0.
Manual effort: Premium Agent mode eliminates nearly all hands-on approvals, thereby speeding up the build process.
Take a look at the prompt used for testing and a YouTube walkthrough of this process.
GitHub Copilot Agent Mode Prompt
## AI Agent Prompt: Deck of Cards API with .NET 8 and MS SQL
**Objective:**
Build a .NET 8 API application (C#) that simulates a deck of cards, using a local MS SQL database for persistence. The solution folder should be named `DeckOfCards`. Before coding, generate and present a detailed project outline for review and approval. Once the plan is approved, do not request additional approvals. Proceed to create all required items without interruption, unless an explicit approval is essential for compliance or technical reasons. This ensures a smooth, uninterrupted workflow.
---
### 1. Project Outline
* Create an outline detailing each step to build the application, covering data modeling, API design, error handling, and testing.
* Pause and present the outline for approval before proceeding. No further review is required after approval.
* If you encounter any blocking issues during implementation, stop and document the issue for review.
---
### 2. SQL Data Model
* Design an MS SQL data model to manage multiple unique decks of cards within a `DeckOfCards` database (running locally).
* The model must support:
* Tracking cards for each unique deck.
* Creating a new deck (with a Deck ID as a GUID string without dashes).
* Drawing a specified number of cards from a deck.
* Listing all unused cards for a given deck, with a count of remaining cards.
* Treat Deck IDs as strings at all times.
* Define any variables within the relevant stored procedure.
* Enforce robust error handling for cases such as invalid Deck IDs or attempts to draw more cards than remain.
* Return detailed error messages to the API caller.
* Apply SQL best practices in naming, procedure structure, and artifact organization.
* Atomatically create and deploy the database and scripts using the local SQL server. Create the database called DeckOfCards in Server Localhost, then create the tables and procedures. Otherwise, provide a PowerShell script to fully create the database, tables, and procedures.
---
### 3. API Layer
* Create a new API project with the following endpoints, each with comprehensive unit tests (covering both positive and negative scenarios) and proper exception handling:
* **NewDeck** (GET): Returns a new DeckGuid (GUID string without dashes).
* **DrawCards** (POST):
* Inputs: DeckGuid and NumberOfCards as query parameters.
* Output: JSON array of randomly drawn cards for the specified deck.
* **CardsUsed** (GET):
* Input: DeckGuid as a query parameter.
* Output: JSON array of cards remaining in the deck, including the count of cards left.
* Implement the API using C#, connecting to SQL in the data layer for each method.
* Inside the Tests project, generate unit tests for each stored procedure
* Make sure to check for running out of cards, not able to draw anymore cards, and invaid Deck ID. Create a case for each of these.
* Inside the Tests project, generate unit tests for each API methods.
---
### 4. Application Configuration and Best Practices
* Update the `.http` file to document the three new APIs. Remove any references to the default WeatherForecast API.
* Ensure the APIs are configured to run on HTTP port 5000. Include a correct `launchSettings.json` file.
* Update `Program.cs` for the new API, removing all WeatherForecast-related code.
* Use asynchronous programming (`async/await`), store connection strings securely, and follow .NET and C# best practices throughout.
---
**Note:**
If you cannot complete a step (such as database deployment), clearly document the issue and provide a workaround or an alternative script (e.g., PowerShell for setup).
Once complete, run all unit tests to ensure everything is working.
Postman will be used for testing. Provide a inport file to be used with PostMan to test each of the three APIs. Ensure to use the HTTP endpoint.
Take a look at my YouTube Video talking through this demo step-bystep.
Conclusion & Next Steps
YES! The GitHub Copilot Pro play is worth the money!
Investing in a premium Copilot subscription ($10/month) is worthwhile for professional developers who want to automate full-stack builds and maximize code reliability.
The workflow shown here—prompt engineering, agent automation, and integrated testing—can be applied to a range of development tasks.
Recent Comments