efcore-postgresql
Skill1 starsChanged 3 months agoApache-2.0View on GitHub
Use for EF Core and PostgreSQL data access, query tuning, migrations, concurrency, and persistence reviews.
In this repository14 other files it gives its agents.
- aspnet-core-apiSkill
- aspnet-mvcSkill
- blazorSkill
- docker-dotnetSkill
- dotnet-expertSkill
- dotnet-file-based-appsSkill
- dotnet-messagingSkill
- dotnet-observabilitySkill
- dotnet-performanceSkill
- dotnet-testingSkill
- dotnet-version-guideSkill
- gitlab-basicsSkill
- gitlab-ci-dotnetSkill
- pandocSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 20 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Use for entities, configurations, DbContext, repositories, LINQ queries, migrations, transactions, concurrency, indexes, and …
- Distinctive: line 29
Do not use for non-.NET data access, database administration unrelated to application code, or API-only changes with no persistence impact.
- Distinctive: line 35
Write the smallest intention-revealing query and inspect generated SQL for important paths.
- Distinctive: line 36
Add constraints and indexes in the database model, not only in application checks.
- Distinctive: line 37
Test provider-specific behavior against PostgreSQL, not an in-memory fake.
- Distinctive: line 38
Run migrations, build, and integration tests.
- Distinctive: line 42
Use AsNoTracking for read-only queries.
- Distinctive: line 44
Avoid lazy loading and accidental N+1 queries.
- Distinctive: line 46
Prefer keyset pagination for large tables.
- Distinctive: line 47
Do not expose IQueryable outside the persistence boundary.
- Distinctive: line 48
Use ExecuteUpdate and ExecuteDelete deliberately.
- Distinctive: line 50
Treat SqlNullValueException as a nullability/model mismatch.
- Distinctive: line 54
Use PostgreSQL types intentionally: timestamptz, jsonb, arrays, UUID, and numeric precision.
- Distinctive: line 55
Use UTC instants and map them consistently.
- Distinctive: line 56
Use unique and partial indexes when business rules require them.
- Distinctive: line 57
Use optimistic concurrency explicitly.
- Distinctive: line 59
Use EXPLAIN (ANALYZE, BUFFERS) for measured query investigations.
- Distinctive: line 60
Keep migrations reviewable and generate idempotent production scripts or bundles.
- Distinctive: line 64
Keep transaction boundaries at the use-case level when multiple writes must be atomic.
- Distinctive: line 68
Check SQL shape, indexes, nullability, tracking mode, transaction scope, cancellation, migration safety, and real-PostgreSQL integration …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
EF Core and PostgreSQL
When to Use
Use for entities, configurations, DbContext, repositories, LINQ queries, migrations, transactions, concurrency, indexes, and PostgreSQL-specific behavior.
When Not to Use
Do not use for non-.NET data access, database administration unrelated to application code, or API-only changes with no persistence impact.
Workflow
- Inspect provider, EF Core version, naming conventions, migrations, nullability, and DbContext lifetime.
- Identify whether the operation is a read, tracked update, bulk operation, migration, or transaction.
- Write the smallest intention-revealing query and inspect generated SQL for important paths.
- Add constraints and indexes in the database model, not only in application checks.
- Test provider-specific behavior against PostgreSQL, not an in-memory fake.
- Run migrations, build, and integration tests.
Query Rules
- Use AsNoTracking for read-only queries.
- Project to DTOs instead of loading complete graphs.
- Avoid lazy loading and accidental N+1 queries.
- Apply deterministic ordering and bounded pagination.
- Prefer keyset pagination for large tables.
- Do not expose IQueryable outside the persistence boundary.
- Use ExecuteUpdate and ExecuteDelete deliberately; they bypass change tracking.
- Pass CancellationToken to every async database call.
- Treat SqlNullValueException as a nullability/model mismatch.
PostgreSQL Rules
- Use PostgreSQL types intentionally: timestamptz, jsonb, arrays, UUID, and numeric precision.
- Use UTC instants and map them consistently.
- Use unique and partial indexes when business rules require them.
- Use optimistic concurrency explicitly. With Npgsql, xmin can be a concurrency token; SQL Server rowversion is not portable.
- Parameterize values and never concatenate user input into SQL.
- Use EXPLAIN (ANALYZE, BUFFERS) for measured query investigations.
- Keep migrations reviewable and generate idempotent production scripts or bundles.
Transactions and Reliability
Keep transaction boundaries at the use-case level when multiple writes must be atomic. Consider an outbox for database-plus-message consistency. Handle unique-constraint and serialization failures as expected conflicts where appropriate.
Quality Gate
Check SQL shape, indexes, nullability, tracking mode, transaction scope, cancellation, migration safety, and real-PostgreSQL integration coverage.
Example: Bounded Read and Concurrency
var orders = await db.Orders
.AsNoTracking()
.Where(x => x.CustomerId == customerId && x.Id > afterId)
.OrderBy(x => x.Id)
.Select(x => new OrderListItem(x.Id, x.Status, x.CreatedAt))
.Take(Math.Clamp(pageSize, 1, 100))
.ToListAsync(ct);
var changed = await db.Orders
.Where(x => x.Id == id && x.Version == expectedVersion)
.ExecuteUpdateAsync(setters => setters
.SetProperty(x => x.Status, OrderStatus.Paid)
.SetProperty(x => x.UpdatedAt, DateTimeOffset.UtcNow), ct);
if (changed == 0)
throw new ConcurrencyException("The order was changed or deleted.");The first query uses keyset pagination and projection. ExecuteUpdate bypasses change tracking, so do not expect an already tracked entity to be updated in memory. Use a transaction when several writes must be atomic.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

