Skip to content

Conversation

@devin-ai-integration
Copy link

Phase 2: Data Layer Migration from Entity Framework 6.1.3 to Entity Framework Core

Summary

This PR implements Phase 2 of the .NET Framework to .NET Core migration, migrating the DataLayer from Entity Framework 6.1.3 to Entity Framework Core 8.0. Building on the Phase 1 infrastructure, this adds the actual EF Core implementation with migrated entity classes, DbContext, and database initialization logic.

Key changes:

  • Updated DataLayer.Core and ServiceLayer.Core to target net8.0 (required for EF Core 8.0)
  • Migrated entity classes (Blog, Post, Tag) with all validation logic preserved
  • Created SampleWebAppDbCore DbContext with change tracking via TrackUpdate pattern
  • Configured entity relationships and Tag Slug uniqueness constraint in OnModelCreating
  • Added DataLayerCoreInitialise for database initialization and LoadDbDataFromXml for data seeding
  • Added 15 unit tests covering DbContext creation, entity CRUD, relationships, and validation

Build status: Succeeded with 25 nullable reference type warnings (CS8618) - these are expected when migrating legacy code to nullable-enabled projects.

Review & Testing Checklist for Human

  • Verify Post-Tag many-to-many relationship - EF Core auto-generates the join table; confirm the generated schema matches the original EF6 database schema or that migration is acceptable
  • Test against actual SQL Server - All unit tests use InMemory provider which doesn't enforce SQL constraints; verify Tag Slug uniqueness and foreign keys work correctly against real database
  • Review nullable warnings - 25 CS8618 warnings exist for non-nullable properties; decide if these need required modifier or nullable annotations
  • Validate connection string configuration - DefaultConnectionString uses LocalDB (Windows-only); verify this is acceptable for your deployment scenario

Recommended test plan:

  1. Run dotnet build SampleMvcWebApp.Core.sln --configuration Release - should succeed with warnings
  2. Run dotnet test SampleMvcWebApp.Core.sln - all 15 tests should pass
  3. If possible, test DbContext against actual SQL Server LocalDB to verify schema generation matches expectations
  4. Compare generated EF Core schema with original EF6 database schema for the Post-Tag join table

Notes

  • The original EF6 ValidateEntity override for Tag Slug uniqueness is now handled via HasIndex().IsUnique() in OnModelCreating
  • XML data files for seeding (BlogsContentSimple.xml, BlogsContextMedium.xml) are embedded resources
  • This PR targets the Phase 1 branch, not master

Link to Devin run: https://app.devin.ai/sessions/88606214e3b14e1681a1d720b725fa31
Requested by: Abhay Aggarwal (abhay.aggarwal@cognition.ai) / @abhay-codeium

…ramework Core

- Update DataLayer.Core to target net8.0 with EF Core 8.0 packages
- Migrate entity classes (Blog, Post, Tag) with validation logic preserved
- Create SampleWebAppDbCore DbContext with change tracking and model configuration
- Add TrackUpdate helper class for LastUpdated tracking
- Create DataLayerCoreInitialise for database initialization
- Add LoadDbDataFromXml helper for seeding data from XML files
- Copy XML data files (BlogsContentSimple.xml, BlogsContextMedium.xml)
- Update ServiceLayer.Core to target net8.0 for compatibility
- Add comprehensive unit tests for DataLayer.Core (15 tests)
- Configure Tag Slug uniqueness constraint in OnModelCreating
- Preserve all entity relationships (Blog-Post, Post-Tag many-to-many)

Co-Authored-By: Abhay Aggarwal <abhay.aggarwal@codeium.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant