ef-core
Skill này làm gì
Agent này giúp bạn viết code Entity Framework Core tốt hơn và hiệu quả hơn. Entity Framework Core là công cụ làm việc với cơ sở dữ liệu trong C#.
Khi nào nên dùng
- ✓Khi tạo hoặc sửa code dùng Entity Framework Core.
- ✓Khi bạn muốn bảo đảm code nhanh và an toàn.
- ✓Khi bạn gặp vấn đề về hiệu năng hoặc lỗi cơ sở dữ liệu.
Liên kết skill
https://github.com/github/awesome-copilot/blob/main/skills/ef-core/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm sao để tối ưu các truy vấn để tránh cơ sở dữ liệu bị chậm?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent so sánh code của bạn với bộ quy tắc và thực hành tốt nhất. Nếu tìm thấy điểm có thể cải thiện, nó gợi ý cách làm.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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.
Câu hỏi thường gặp
Entity Framework Core là gì?
Đó là công cụ giúp chương trình viết bằng C# giao tiếp với cơ sở dữ liệu dễ hơn, mà không cần viết lệnh SQL phức tạp.
“Thực hành tốt nhất” là gì?
Đó là những cách làm được biết đến rộng rãi nhất, thường cho code nhanh hơn, an toàn hơn và dễ bảo trì hơn.
Tôi có cần biết nhiều về cơ sở dữ liệu để dùng không?
Không. Agent được thiết kế để giúp ngay cả khi bạn mới làm quen với Entity Framework Core.
Chi tiết
Độ phổ biến
- Sao GitHub
- 40k
- Vị trí xếp hạng
- #7186
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
acquire-codebase-knowledge
40kGiúp agent của bạn hiểu và ghi tài liệu cho một dự án mã nguồn có sẵn. Hữu ích khi đón thành viên mới hoặc nắm tổng quan về kiến trúc.
acreadiness-assess
40kGiúp agent của bạn đánh giá mức độ sẵn sàng cho AI của dự án và tạo báo cáo. Hữu ích để biết dự án đã sẵn sàng dùng công cụ AI đến đâu.
acreadiness-generate-instructions
40kGiúp agent của bạn tạo hướng dẫn cho công cụ AI dựa trên kết quả đánh giá. Hữu ích để cải thiện cách AI làm việc với mã và khắc phục các khoảng trống.
acreadiness-policy
40kGiúp agent của bạn xác định hoặc áp dụng chính sách đánh giá dự án bằng AI. Hữu ích để chuẩn hóa cách đánh giá dự án và đảm bảo tuân thủ.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.