I recently ran an experiment using GitHub Copilot in Visual Studio 2026 to see whether it could generate repetitive code based on a custom coding convention.
The goal was simple:
Can Copilot adopt a predefined boilerplate template and reuse it across projects?
This is part of a larger series where I’m rewriting a legacy .NET Framework application (with poor coding standards) into a modern solution. In this segment, I focused specifically on the Data Access Layer, using:
- Entity Framework
- Repository Pattern
- Unit of Work
Watch Video here
The Problem
The legacy solution has no consistent coding standards.
Instead of asking Copilot to generate a generic repository implementation, I wanted it to follow my structured convention, which includes:
- A specific folder structure
- Custom namespace rules
- A local NuGet package with reusable plumbing code
Normally, Agent Skills would be ideal for this type of reusable instruction set — but Agent Skills are not yet available in Visual Studio 2026.
Workaround
I used a Markdown (.md) file to store the reference structure and reusable conventions, effectively simulating a small training document for Copilot.
Experiment Setup
I provided Copilot with:
- ✅ A local NuGet package (generic repository, unit of work, EF DbContext setup)
- ✅ An example project layout following my conventions
- ✅ Clear instructions on how the updated solution should be structured
The objective was to see whether Copilot could:
- Understand the example
- Generalize the pattern
- Apply it consistently to the legacy codebase
The Process
1️⃣ Provide Reference Template
Copilot was given a full example of how the Data Access project should look.
2️⃣ Plan Generation
Before touching code, I asked Copilot to generate:
- A structured plan
- The expected folder hierarchy
3️⃣ Install Local NuGet Package
Copilot successfully installed the local NuGet package containing reusable plumbing components.
What Happened
🔹 Initial Planning
Copilot defaulted to a generic repository implementation rather than strictly following my custom pattern.
Even with explicit instructions, it leaned toward common internet-based implementations.
🔹 Folder Structure Issues
Folders starting with underscores caused repeated path errors.
Even after corrections, Copilot occasionally reverted to incorrect folder references.
This suggests that non-standard folder naming conventions can introduce instability in generation.
🔹 Code Generation
Copilot was able to:
- Generate CRUD methods
- Scaffold repository classes
- Create basic EF configurations
However, it did not replicate the architectural intent from the example.
It produced fragments of functionality, but not a clean, reusable pattern aligned with the provided template.
🔹 Minor but Time-Consuming Errors
Across ~20 entities:
- Incorrect namespaces
- Missing
usingstatements - Small structural inconsistencies
These are trivial fixes manually — but through Agent Mode, the iteration cycle became slow enough to impact productivity.
🔹 Extra Unrequested Steps
Copilot also attempted to:
- Wire dependency injection
- Register DbContext
- Trigger builds
None of these were requested.
These additions required cleanup and adjustment.
Key Takeaway
Copilot works well for:
- Standard CRUD scaffolding
- Common repository patterns
- Boilerplate generation
It struggles with:
- Project-specific architecture
- Custom folder conventions
- Pattern generalization from examples
- Maintaining context across multiple prompts
Technical Lessons
1. Pre-Built Patterns Only
Copilot performs best when using widely recognized patterns.
2. Custom Conventions Require Review
It does not automatically internalize team-specific standards.
3. Folder & Namespace Sensitivity
Non-standard folder structures increase error rates.
4. Context Persistence is Limited
Understanding does not reliably persist across interactions in Visual Studio 2026.
5. Productivity Must Be Measured
Even small repeated corrections can negate time savings.
Final Result
In this workflow:
- ❌ Development speed did not improve
- ✅ CRUD scaffolding worked
- ❌ Architecture replication failed
- ❌ Minor fixes consumed more time than manual editing
Conclusion:
GitHub Copilot is effective for generating standard patterns and repetitive code.
For legacy refactoring with strict custom conventions, manual oversight remains essential.
Next Steps
I’ll continue experimenting with:
- Markdown-based reusable instruction sets
- Refining prompts for architectural consistency
- Testing future Agent Skill updates in Visual Studio
If Copilot improves context retention and custom pattern learning, this workflow could become significantly more effective.
If you're using Copilot in enterprise or legacy .NET environments, I'd be interested in hearing your experience.
Have you successfully trained it to follow project-specific standards?


Top comments (0)