{"id":"a153ab2e-85db-4a97-9ebc-4508254104ca","slug":"ef-core","kind":"skill","name":"ef-core","summary":"Get best practices for Entity Framework Core","owner":"github","repoUrl":"https://github.com/github/awesome-copilot/tree/HEAD/skills/ef-core","license":"MIT","licenseTier":"permissive","trust":"official","stars":39994,"match":null,"fewStars":false,"format":"skill","createdAt":null,"addedAt":"2026-10-14T05:11:43.428Z","logoUrl":"https://avatars.githubusercontent.com/u/9919?v=4","linkOnly":false,"collection":{"name":"awesome-copilot","repo":"github/awesome-copilot"},"skillPath":"skills/ef-core","categories":["developer-tools"],"tags":["ai","github-copilot","prompt-engineering","hacktoberfest","agents","awesome","custom-agents"],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-14T05:11:43.426Z","sample":false,"url":"https://conduits.dev/tools/ef-core","language":"JavaScript","transports":[],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# Entity Framework Core Best Practices\n\nYour goal is to help me follow best practices when working with Entity Framework Core.\n\n## Data Context Design\n\n- Keep DbContext classes focused and cohesive\n- Use constructor injection for configuration options\n- Override OnModelCreating for fluent API configuration\n- Separate entity configurations using IEntityTypeConfiguration\n- Consider using DbContextFactory pattern for console apps or tests\n\n## Entity Design\n\n- Use meaningful primary keys (consider natural vs surrogate keys)\n- Implement proper relationships (one-to-one, one-to-many, many-to-many)\n- Use data annotations or fluent API for constraints and validations\n- Implement appropriate navigational properties\n- Consider using owned entity types for value objects\n\n## Performance\n\n- Use AsNoTracking() for read-only queries\n- Implement pagination for large result sets with Skip() and Take()\n- Use Include() to eager load related entities when needed\n- Consider projection (Select) to retrieve only required fields\n- Use compiled queries for frequently executed queries\n- Avoid N+1 query problems by properly including related data\n\n## Migrations\n\n- Create small, focused migrations\n- Name migrations descriptively\n- Verify migration SQL scripts before applying to production\n- Consider using migration bundles for deployment\n- Add data seeding through migrations when appropriate\n\n## Querying\n\n- Use IQueryable judiciously and understand when queries execute\n- Prefer strongly-typed LINQ queries over raw SQL\n- Use appropriate query operators (Where, OrderBy, GroupBy)\n- Consider database functions for complex operations\n- Implement specifications pattern for reusable queries\n\n## Change Tracking & Saving\n\n- Use appropriate change tracking strategies\n- Batch your SaveChanges() calls\n- Implement concurrency control for multi-user scenarios\n- Consider using transactions for multiple operations\n- Use appropriate DbContext lifetimes (scoped for web apps)\n\n## Security\n\n- Avoid SQL injection by using parameterized queries\n- Implement appropriate data access permissions\n- Be careful with raw SQL queries\n- Consider data encryption for sensitive information\n- Use migrations to manage database user permissions\n\n## Testing\n\n- Use in-memory database provider for unit tests\n- Create separate testing contexts with SQLite for integration tests\n- Mock DbContext and DbSet for pure unit tests\n- Test migrations in isolated environments\n- Consider snapshot testing for model changes\n\nWhen reviewing my EF Core code, identify issues and suggest improvements that follow these best practices."}