Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

dotnet-data-access-strategy

БесплатноБез исполняемых скриптовНе проверен

Choosing a data access approach. EF Core vs Dapper vs ADO.NET decision matrix, performance tradeoffs.

wshaddixот wshaddix★ 94 звезды на GitHub

Об этом скилле

dotnet-data-access-strategy

Decision framework for choosing between Entity Framework Core, Dapper, and raw ADO.NET in .NET applications. Covers performance tradeoffs, feature comparisons, AOT/trimming compatibility, hybrid approaches, and migration paths. Use this skill to make an informed technology decision before writing data access code.

Out of scope: Tactical EF Core usage (DbContext lifecycle, migrations, interceptors) is covered in [skill:dotnet-efcore-patterns]. Strategic EF Core architecture (read/write split, aggregate boundaries, repository policy) is covered in [skill:dotnet-efcore-architecture]. DI container mechanics -- see [skill:dotnet-csharp-dependency-injection]. Async patterns -- see [skill:dotnet-csharp-async-patterns]. Testing data access layers -- see [skill:dotnet-integration-testing] for database fixture and Testcontainers patterns. CI/CD pipelines -- see [skill:dotnet-gha-patterns] and [skill:dotnet-ado-patterns].

Cross-references: [skill:dotnet-efcore-patterns] for tactical EF Core usage, [skill:dotnet-efcore-architecture] for strategic EF Core patterns, [skill:dotnet-csharp-dependency-injection] for service registration, [skill:dotnet-csharp-async-patterns] for async query patterns.


Decision Matrix

Factor EF Core Dapper Raw ADO.NET
Learning curve Moderate (LINQ, migrations, config) Low (SQL + mapping) Low-moderate (SQL + manual mapping)
Productivity High (change tracking, migrations, scaffolding) Moderate (write SQL, auto-map) Low (everything manual)
Query performance Good with projections; overhead from tracking Near-ADO.NET performance Fastest possible
Startup time Higher (model building, compilation) Minimal Minimal
Memory allocation Higher (change tracker, proxy objects) Low (direct mapping) Lowest
AOT/trimming Limited (reflection-heavy, improving) Good with source generators Full support
Change tracking Built-in None None
Migrations Built-in None (use FluentMigrator, DbUp, etc.) None
LINQ support Full (translated to SQL) None (raw SQL) None (raw SQL)
Batch operations ExecuteUpdate/ExecuteDelete (EF Core 7+) Manual batching Manual batching
Complex mappings Excellent (owned types, TPH/TPT/TPC) Simple POCO mapping Manual

When to Choose Each

Choose EF Core When

  • Building CRUD applications with standard domain models
  • You need change tracking and automatic dirty detection
  • You want schema migrations managed in code
  • Your team prefers LINQ over raw SQL
  • You are building with .NET Aspire (EF Core has first-class Aspire integration)
  • Query performance is acceptable with projections and AsNoTracking()
// EF Core: expressive, type-safe, with change tracking
var order = await db.Orders
    .Include(o => o.Items)
    .FirstOrDefaultAsync(o => o.Id == orderId, ct);

order!.Status = OrderStatus.Shipped;
await db.SaveChangesAsync(ct); // Automatic dirty detection

Choose Dapper When

  • Performance is critical and you need control over SQL
  • You are writing complex queries (reporting, analytics, multi-join)
  • You need thin data access with minimal abstraction
  • Your team is comfortable writing and maintaining SQL
  • You need AOT compatibility today (with Dapper.AOT source generator)
// Dapper: direct SQL, minimal overhead
await using var connection = new NpgsqlConnection(connectionString);

var orders = await connection.QueryAsync<OrderDto>(
    """
    SELECT o.id, o.customer_id, o.status, o.created_at,
           COUNT(i.id) AS item_count,
           SUM(i.quantity * i.unit_price) AS total
    FROM orders o
    LEFT JOIN order_items i ON i.order_id = o.id
    WHERE o.customer_id = @CustomerId
    GROUP BY o.id, o.customer_id, o.status, o.created_at
    ORDER BY o.created_at DESC
    LIMIT @PageSize
    """,
    new { CustomerId = customerId, PageSize = pageSize });

Choose Raw ADO.NET When

  • Maximum performance is non-negotiable (sub-millisecond data access)
  • You need full control over connection, command, and reader lifecycle
  • You are building a library or framework (no app-level dependencies)
  • AOT compatibility is required and no source generators are acceptable
  • You are working with stored procedures or database-specific features
// Raw ADO.NET: full control, zero abstraction overhead
await using var connection = new NpgsqlConnection(connectionString);
await connection.OpenAsync(ct);

await using var command = connection.CreateCommand();
command.CommandText = "SELECT id, name, price FROM products WHERE category_id = $1";
command.Parameters.AddWithValue(categoryId);

await using var reader = await command.ExecuteReaderAsync(ct);
var products = new List<ProductDto>();

while (await reader.ReadAsync(ct))
{
    products.Add(new ProductDto
    {
        Id = reader.GetInt32(0),
        Name
Полный SKILL.md на GitHub

Установить dotnet-data-access-strategy в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл dotnet-data-access-strategy?

Choosing a data access approach. EF Core vs Dapper vs ADO.NET decision matrix, performance tradeoffs.

Как установить скилл dotnet-data-access-strategy?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл dotnet-data-access-strategy запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить dotnet-data-access-strategy с