Saltar al contenido
Skillpedia
Programación general40 mil · #7186

ef-core

Qué hace

Este agente te ayuda a escribir código mejor y más eficiente para Entity Framework Core, una herramienta para trabajar con bases de datos en C#.

Cuándo usarla

  • ✓Cuando creas o modificas código que usa Entity Framework Core.
  • ✓Cuando quieres asegurarte de que tu código sea rápido y seguro.
  • ✓Si tienes problemas de rendimiento o errores con la base de datos.

Link de la skill

https://github.com/github/awesome-copilot/blob/main/skills/ef-core/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/github/awesome-copilot/blob/main/skills/ef-core/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Cómo puedo optimizar mis consultas para evitar que la base de datos vaya lenta?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Compara tu código con un conjunto de reglas y buenas prácticas. Si encuentra algo que se puede mejorar, te sugiere cómo hacerlo.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

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.

Preguntas frecuentes

¿Qué es Entity Framework Core?

Es una herramienta que facilita que tu programa (escrito en C#) se comunique con una base de datos, sin necesidad de escribir comandos SQL complejos.

¿Qué son las "buenas prácticas"?

Son las formas más conocidas de hacer algo bien, que normalmente dan como resultado código más rápido, más seguro y más fácil de mantener.

¿Necesito saber mucho de bases de datos para usarlo?

No, el agente está diseñado para ayudarte aunque seas nuevo en Entity Framework Core.

Detalles

Descripción original del autor

Get best practices for Entity Framework Core

repo: github/awesome-copilot

Popularidad

Estrellas en GitHub
40 mil
Posición en el ranking
#7186
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas