agentleFS
RorroRojas3RorroRojas3/maf-agents/.claude/skills/ef-core/SKILL.md

ef-core

Skill0 starsChanged 2 months agoMITView on GitHub

Get best practices for Entity Framework Core

5 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

30 rules. 0 are common, 30 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 30

    Distinctive

    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
  1. Distinctive:

    Keep DbContext classes focused and cohesive

    line 12
  2. Distinctive:

    Use constructor injection for configuration options

    line 13
  3. Distinctive:

    Consider using DbContextFactory pattern for console apps or tests

    line 16
  4. Distinctive:

    Use meaningful primary keys (consider natural vs surrogate keys)

    line 20
  5. Distinctive:

    Use data annotations or fluent API for constraints and validations

    line 22
  6. Distinctive:

    Consider using owned entity types for value objects

    line 24
  7. Distinctive:

    Use AsNoTracking() for read-only queries

    line 28
  8. Distinctive:

    Use Include() to eager load related entities when needed

    line 30
  9. Distinctive:

    Consider projection (Select) to retrieve only required fields

    line 31
  10. Distinctive:

    Use compiled queries for frequently executed queries

    line 32
  11. Distinctive:

    Avoid N+1 query problems by properly including related data

    line 33
  12. Distinctive:

    Create small, focused migrations

    line 37
  13. Distinctive:

    Verify migration SQL scripts before applying to production

    line 39
  14. Distinctive:

    Consider using migration bundles for deployment

    line 40
  15. Distinctive:

    Add data seeding through migrations when appropriate

    line 41
  16. Distinctive:

    Use IQueryable judiciously and understand when queries execute

    line 45
  17. Distinctive:

    Prefer strongly-typed LINQ queries over raw SQL

    line 46
  18. Distinctive:

    Use appropriate query operators (Where, OrderBy, GroupBy)

    line 47
  19. Distinctive:

    Consider database functions for complex operations

    line 48
  20. Distinctive:

    Use appropriate change tracking strategies

    line 53
  21. Distinctive:

    Consider using transactions for multiple operations

    line 56
  22. Distinctive:

    Use appropriate DbContext lifetimes (scoped for web apps)

    line 57
  23. Distinctive:

    Avoid SQL injection by using parameterized queries

    line 61
  24. Distinctive:

    Consider data encryption for sensitive information

    line 64
  25. Distinctive:

    Use migrations to manage database user permissions

    line 65
  26. Distinctive:

    Use in-memory database provider for unit tests

    line 69
  27. Distinctive:

    Create separate testing contexts with SQLite for integration tests

    line 70
  28. Distinctive:

    Test migrations in isolated environments

    line 72
  29. Distinctive:

    Consider snapshot testing for model changes

    line 73
  30. Distinctive:

    When reviewing my EF Core code, identify issues and suggest improvements that follow these best practices.

    line 75

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Entity Framework Core Best Practices

Your goal is to help me follow best practices when working with Entity Framework Core.

Data Context Design

  • Keep DbContext classes focused and cohesive
  • Use constructor injection for configuration options
  • Override OnModelCreating for fluent API configuration
  • Separate entity configurations using IEntityTypeConfiguration
  • Consider using DbContextFactory pattern for console apps or tests

Entity Design

  • Use meaningful primary keys (consider natural vs surrogate keys)
  • Implement proper relationships (one-to-one, one-to-many, many-to-many)
  • Use data annotations or fluent API for constraints and validations
  • Implement appropriate navigational properties
  • Consider using owned entity types for value objects

Performance

  • Use AsNoTracking() for read-only queries
  • Implement pagination for large result sets with Skip() and Take()
  • Use Include() to eager load related entities when needed
  • Consider projection (Select) to retrieve only required fields
  • Use compiled queries for frequently executed queries
  • Avoid N+1 query problems by properly including related data

Migrations

  • Create small, focused migrations
  • Name migrations descriptively
  • Verify migration SQL scripts before applying to production
  • Consider using migration bundles for deployment
  • Add data seeding through migrations when appropriate

Querying

  • Use IQueryable judiciously and understand when queries execute
  • Prefer strongly-typed LINQ queries over raw SQL
  • Use appropriate query operators (Where, OrderBy, GroupBy)
  • Consider database functions for complex operations
  • Implement specifications pattern for reusable queries

Change Tracking & Saving

  • Use appropriate change tracking strategies
  • Batch your SaveChanges() calls
  • Implement concurrency control for multi-user scenarios
  • Consider using transactions for multiple operations
  • Use appropriate DbContext lifetimes (scoped for web apps)

Security

  • Avoid SQL injection by using parameterized queries
  • Implement appropriate data access permissions
  • Be careful with raw SQL queries
  • Consider data encryption for sensitive information
  • Use migrations to manage database user permissions

Testing

  • Use in-memory database provider for unit tests
  • Create separate testing contexts with SQLite for integration tests
  • Mock DbContext and DbSet for pure unit tests
  • Test migrations in isolated environments
  • Consider snapshot testing for model changes

When reviewing my EF Core code, identify issues and suggest improvements that follow these best practices.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.