comprehensive EF Core + .NET Core coding and architecture practice roadmap
1. EF Core: Core CRUD & Mapping Practice
Goal: Master EF Core fundamentals and database mapping.
Tasks:
- Create a .NET
Core Web API project.
- Define DbContext and models with:
- Data annotations
- Fluent API mapping
- Implement basic CRUD for Employee, Project, Invoice.
- Practice relationship mapping:
- One-to-one
- One-to-many
- Many-to-many
- Explore shadow properties & computed columns.
- Use AsNoTracking() for read-only queries to test performance.
Mini Coding Exercise:
- Build Employee-Project management API with CRUD.
- Test queries with tracking vs no-tracking and measure
performance.
2.
EF Core: Advanced Features & Performance
Goal: Optimize queries and understand advanced EF Core behavior.
Tasks:
- Query Optimization
- Include(),
ThenInclude() for eager loading.
- Explicit loading vs lazy loading.
- Projection with Select() for DTOs.
- Batch Operations
- ExecuteUpdate,
ExecuteDelete
- Performance Tools
- ToQueryString()
to see generated SQL.
- Logging SQL queries for profiling.
- Index creation via Fluent API.
- Caching / No-Tracking
- Read-heavy APIs → AsNoTracking()
- Optional: Redis caching for frequent queries.
Mini Coding Exercise:
- Create a dashboard API for invoices that aggregates
data.
- Optimize queries using projections and no-tracking.
3.
Security in EF Core & .NET Core APIs
Goal: Learn how to secure data access and prevent
vulnerabilities.
Tasks:
- Authentication & Authorization
- Implement JWT Authentication.
- Role-based access: Admin vs User.
- Prevent SQL Injection
- EF Core parameterized queries are safe by default.
- Dapper: always use parameters, never string
interpolation.
- Data Protection
- Hash passwords (BCrypt or ASP.NET Identity).
- Use DTOs to avoid exposing sensitive fields.
Mini Coding Exercise:
- Implement login/register endpoints.
- Protect invoice APIs: only owners or admins can access.
- Attempt injection with raw SQL (simulate attack) → see
EF Core safe handling.
4.
Dapper: Micro-ORM Practice
Goal: Learn when to use Dapper vs EF Core, and how to integrate
both.
Tasks:
- Install Dapper and connect to SQL Server.
- Write parameterized queries for:
- Select
- Insert
- Update
- Delete
- Compare performance with EF Core for heavy read
scenarios.
- Combine Dapper with EF Core in same app:
- Use EF Core for entity management
- Use Dapper for high-performance reporting queries
Mini Coding Exercise:
- Create a report API that fetches top 10 invoices per
client using Dapper.
- Measure execution time vs EF Core.
5.
Application Architecture & Patterns
Goal: Design scalable, maintainable apps.
Tasks:
- Design Patterns
- Repository + Unit of Work with EF Core
- CQRS with MediatR
- Factory / Strategy (e.g., Payment Gateway selection)
- Layering
- Separate Projects: API / Core / Infrastructure
- Dependency Injection for services and repositories
- Exception Handling
- Global exception middleware
- Logging with Serilog or NLog
Mini Coding Exercise:
- Refactor invoice app using Repository + Unit of Work.
- Implement CQRS for Invoice creation vs Invoice
reporting.
6.
Advanced EF Core: Migration & Maintenance
Tasks:
- Create migrations, update database.
- Seed initial data programmatically.
- Handle multiple DbContexts in same app.
- Soft delete vs hard delete patterns.
7.
Testing & CI/CD
Goal: Ensure code correctness and maintainability.
Tasks:
- Unit test repositories with InMemoryDbContext.
- Integration tests for API endpoints.
- Automate database migration in CI/CD pipeline.
- Performance tests: measure query execution, EF vs
Dapper.
8.
Mini Project: Full EF Core + Dapper + Secure API
Scenario: Invoice Management System
- Entities:
Employee, Project, Client, Invoice, Payment
- Features:
- CRUD for all entities (EF Core)
- Reporting endpoints (Dapper for heavy reads)
- JWT-based Auth + Role-based access
- Optimized queries, no-tracking where applicable
- CQRS for Invoice Creation vs Invoice Reporting
- Pagination + Filtering + Sorting
- Logging + Exception handling
Bonus: Generate PDF reports using invoice data.
✅ Extra Focus Areas for Coding
Interviews
- EF Core vs Dapper differences & trade-offs
- Tracking vs NoTracking
- Eager vs Lazy loading
- Raw SQL in EF Core
- Performance pitfalls: N+1 queries, large data fetch
- Security: JWT, SQL Injection, Sensitive data exposure
- Clean architecture & dependency injection
Comments
Post a Comment