Skip to content

[BD-847] Migrate from Dapper to Entity Framework Core#21

Merged
Ranganathan-code-ops merged 2 commits intomainfrom
feature/orch-001/BD-847-prisma-orm-integration
Feb 13, 2026
Merged

[BD-847] Migrate from Dapper to Entity Framework Core#21
Ranganathan-code-ops merged 2 commits intomainfrom
feature/orch-001/BD-847-prisma-orm-integration

Conversation

@Ranganathan-code-ops
Copy link
Copy Markdown
Collaborator

@Ranganathan-code-ops Ranganathan-code-ops commented Feb 12, 2026

Summary

Migrate from Dapper to Entity Framework Core for multi-database support and improved maintainability.

  • Replace Dapper ORM with EF Core, supporting SQL Server, MySQL, and PostgreSQL via DatabaseProviderFactory
  • Create 6 entity classes mapping to production database tables with proper attribute-based column mappings
  • Add OrderMonitorDbContext with fluent relationship configuration and NoTracking default
  • Implement EfCoreOrderRepository using pure LINQ (zero raw SQL in repository layer)
  • Move all SQL-specific date/time logic (DATEDIFF, GETUTCDATE, LEAD) to C# application layer
  • Add IDiagnosticsService abstraction replacing direct IDbConnectionFactory usage
  • Remove Dapper, SqlConnectionFactory, and IDbConnectionFactory
  • Add 37 new unit tests covering entities, DbContext, repository, and provider factory
  • Add 22 multi-DB integration tests (MySQL 8.0 + PostgreSQL 16) via Testcontainers
  • Add 5 performance benchmarks (500 orders, all queries <2s)

Test Results

  • 211 tests passing (154 unit + 35 integration + 22 multi-DB provider)
  • 5 performance benchmarks all within threshold (<443ms worst case with 500 orders)
  • 0 failures, 0 warnings
  • Validated against real MySQL 8.0 and PostgreSQL 16 via Docker Testcontainers

Files Changed

New (19 files):

  • Data/Entities/ - 6 entity classes
  • Data/OrderMonitorDbContext.cs - EF Core DbContext
  • Data/DatabaseProviderFactory.cs - Multi-provider factory
  • Data/EfCoreOrderRepository.cs - LINQ-based repository
  • Data/DiagnosticsService.cs + IDiagnosticsService.cs
  • 4 unit test files + 4 integration test files (providers + benchmarks)

Modified (6 files):

  • DiagnosticsController.cs - Use service abstraction
  • DependencyInjection.cs - EF Core DI registration
  • Infrastructure.csproj - EF Core packages
  • Test projects - InMemory + Testcontainers packages

Deleted (5 files):

  • OrderRepository.cs, SqlConnectionFactory.cs, IDbConnectionFactory.cs
  • OrderRepositoryTests.cs, SqlConnectionFactoryTests.cs

Closes

BD-847, BD-863, BD-864, BD-865, BD-866, BD-867, BD-868, BD-869, BD-870, BD-871, BD-872, BD-873

🤖 Generated with Claude Code

Replace Dapper ORM with Entity Framework Core for multi-database
support (SQL Server, MySQL, PostgreSQL). Move all SQL-specific
date/time logic to C# application layer for database portability.

Changes:
- Add EF Core entities mapping to production tables
- Add OrderMonitorDbContext with fluent relationship configuration
- Add DatabaseProviderFactory for multi-provider support
- Add EfCoreOrderRepository implementing IOrderRepository via LINQ
- Add IDiagnosticsService and implementation using EF Core
- Update DI registration for EF Core services
- Update DiagnosticsController to use service abstraction
- Remove Dapper, SqlConnectionFactory, and IDbConnectionFactory
- Add 37 new unit tests (entities, DbContext, repository, factory)
- Update integration test factory with InMemory DbContext

189 tests passing (154 unit + 35 integration)

Closes BD-847, BD-863, BD-864, BD-865, BD-866, BD-867, BD-868, BD-869, BD-870

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Ranganathan-code-ops Ranganathan-code-ops force-pushed the feature/orch-001/BD-847-prisma-orm-integration branch from 1d97f0b to 8860f73 Compare February 12, 2026 19:23
Add Testcontainers-based integration tests validating EfCoreOrderRepository
against real MySQL 8.0 and PostgreSQL 16 databases. Add performance
benchmarks with 500 seeded orders confirming sub-2s query times.

Changes:
- Add DatabaseProviderTestBase with shared test scenarios (11 tests)
- Add MySqlProviderTests running against Docker MySQL 8.0
- Add PostgreSqlProviderTests running against Docker PostgreSQL 16
- Add QueryPerformanceTests with 5 benchmarks (500 orders, <2s threshold)
- Add Testcontainers.MySql, Testcontainers.PostgreSql, EF Core provider packages

211 tests passing (154 unit + 35 integration + 22 provider)
All 5 benchmarks within threshold (<443ms worst case)

Closes BD-871, BD-872, BD-873

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Ranganathan-code-ops Ranganathan-code-ops merged commit 0654212 into main Feb 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants