dotnet-data

Guide .NET data access with Entity Framework Core and Dapper best practices.

Updated Feb 5, 2026
One-click install
npx skills add https://github.com/Objective-Arts/lens --skill dotnet-data
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-data
Source: https://github.com/Objective-Arts/lens/tree/main/canon/csharp/dotnet-data
Command: npx skills add https://github.com/Objective-Arts/lens --skill dotnet-data

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses common pitfalls and best practices in .NET data access using Entity Framework Core and Dapper, ensuring efficient, maintainable, and performant data operations.

Core Features & Use Cases

  • EF Core Best Practices: Covers DbContext lifetime, AsNoTracking, N+1 problem solutions, and projections.
  • Dapper Integration: Explains when and how to use Dapper for performance-critical read operations.
  • Migrations & Raw SQL: Guides on managing database schema evolution and using raw SQL safely.
  • Use Case: Optimize a high-traffic e-commerce backend by ensuring all read-only product catalog queries use AsNoTracking and projections, while complex order reporting leverages Dapper for speed.

Quick Start

Use the dotnet-data skill to review the best practices for DbContext lifetime management in a .NET application.

Frequently Asked Questions about dotnet-data

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to optimize EF Core queries for high-traffic read operations?

Optimize EF Core queries by applying AsNoTracking and projections to read-only operations. This prevents unnecessary change tracking overhead, significantly improving performance in high-traffic scenarios like product catalog fetching.

How do I mitigate the N+1 problem in Entity Framework Core?

Mitigate the EF Core N+1 problem by using eager loading with Include or projections. This ensures related data is fetched in a single query rather than executing separate queries for each entity, reducing database round trips.

When should I use Dapper instead of Entity Framework Core?

Use Dapper instead of Entity Framework Core for performance-critical read operations and complex reporting. Dapper provides faster raw SQL execution, while EF Core remains better suited for complex CRUD operations and schema management.

How do I manage database schema migrations safely in .NET data access?

Manage database schema migrations safely in .NET by leveraging EF Core migration strategies. This handles database schema evolution systematically, ensuring data access patterns remain synchronized with structural changes without data loss.

Can I execute raw SQL safely using Entity Framework Core?

You can execute raw SQL safely using Entity Framework Core. The framework provides mechanisms for secure raw SQL execution, allowing you to handle complex reporting or specific queries without exposing the application to SQL injection risks.

What is the recommended DbContext lifetime management for .NET applications?

Recommended DbContext lifetime management for .NET applications typically uses scoped lifetimes. This ensures context instances are shared within a request, preventing memory leaks and managing concurrent data access operations efficiently.