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:

  1. Create a .NET Core Web API project.
  2. Define DbContext and models with:
    • Data annotations
    • Fluent API mapping
  3. Implement basic CRUD for Employee, Project, Invoice.
  4. Practice relationship mapping:
    • One-to-one
    • One-to-many
    • Many-to-many
  5. Explore shadow properties & computed columns.
  6. 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:

  1. Query Optimization
    • Include(), ThenInclude() for eager loading.
    • Explicit loading vs lazy loading.
    • Projection with Select() for DTOs.
  2. Batch Operations
    • ExecuteUpdate, ExecuteDelete
  3. Performance Tools
    • ToQueryString() to see generated SQL.
    • Logging SQL queries for profiling.
    • Index creation via Fluent API.
  4. 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:

  1. Authentication & Authorization
    • Implement JWT Authentication.
    • Role-based access: Admin vs User.
  2. Prevent SQL Injection
    • EF Core parameterized queries are safe by default.
    • Dapper: always use parameters, never string interpolation.
  3. 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:

  1. Install Dapper and connect to SQL Server.
  2. Write parameterized queries for:
    • Select
    • Insert
    • Update
    • Delete
  3. Compare performance with EF Core for heavy read scenarios.
  4. 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:

  1. Design Patterns
    • Repository + Unit of Work with EF Core
    • CQRS with MediatR
    • Factory / Strategy (e.g., Payment Gateway selection)
  2. Layering
    • Separate Projects: API / Core / Infrastructure
    • Dependency Injection for services and repositories
  3. 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:

  1. Create migrations, update database.
  2. Seed initial data programmatically.
  3. Handle multiple DbContexts in same app.
  4. Soft delete vs hard delete patterns.

7. Testing & CI/CD

Goal: Ensure code correctness and maintainability.

Tasks:

  1. Unit test repositories with InMemoryDbContext.
  2. Integration tests for API endpoints.
  3. Automate database migration in CI/CD pipeline.
  4. 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

Popular posts from this blog

Debouncing & Throttling in RxJS: Optimizing API Calls and User Interactions

Promises in Angular

Comprehensive Guide to C# and .NET Core OOP Concepts and Language Features