This guide walks through GitHub Copilot's Agent mode on an ASP.NET Core Web API project: analyze first, plan next, then implement in small reviewed steps. An Employee Management sample covers EF Core, a service layer, unit tests and a copilot-instructions.md file.
Key points
- Agent mode is available in Visual Studio 2022 17.14 and later, picked from the mode selector in Copilot Chat.
- Start with a read-only analysis prompt covering structure, DI, DbContext and existing conventions before edits.
- Requesting and approving a plan first prevents unnecessary files and abstractions from being added.
- The service layer gets async methods such as GetAllAsync, GetByIdAsync, CreateAsync, UpdateAsync and DeleteAsync.
- Review EF Core migrations (`dotnet ef migrations add`, `dotnet ef database update`) before they touch any shared database.
- A `.github/copilot-instructions.md` file carries architecture, security and testing rules without repeating them.
Real-world use
- Adding a new CRUD feature (Employee) to an existing layered ASP.NET Core Web API.
- Generating controller, service and DTO changes step by step in an EF Core and SQL Server project.
- Having Copilot Agent draft unit tests and diagnose failures from `dotnet test` output.
- Carrying team conventions into every Copilot request via copilot-instructions.md.
This summary was generated by the agent from the original post on C# Corner. The full text and all rights belong to its author and publisher. Go to original