Skip to content

Conversation

@van-vothanh
Copy link
Owner

.NET Framework to .NET 8 Migration - Executive Report

📊 Executive Summary

This report documents a comprehensive migration attempt of SmartStoreNET, a large-scale e-commerce application, from .NET Framework 4.7.2 to .NET 8. The migration involved systematic transformation of 10 projects including core libraries, data access layers, web frameworks, and plugin modules. While significant foundational work was completed—including project file modernization, package updates, and pre-build cleanup—the migration revealed the substantial complexity inherent in upgrading legacy ASP.NET MVC/Web API applications. The project successfully eliminated 136 EF6 Index attribute errors and converted all projects to SDK-style format, but 286+ compilation errors remain in the core library alone, primarily related to System.Web dependencies and Entity Framework 6 to EF Core conversions.


🔧 Application Changes

Projects Converted (10 total)

  • SmartStore.Core - Core domain models and infrastructure (SDK-style .NET 8)
  • SmartStore.Data - Data access layer with EF migrations (SDK-style .NET 8)
  • SmartStore.Services - Business logic services (SDK-style .NET 8)
  • SmartStore.Web.Framework - Web framework utilities (SDK-style .NET 8)
  • SmartStore.Web - Main web application (SDK-style .NET 8 Web)
  • SmartStore.Admin - Administration portal (SDK-style .NET 8 Web)
  • SmartStore.OfflinePayment - Payment plugin (SDK-style .NET 8)
  • SmartStore.Tax - Tax calculation plugin (SDK-style .NET 8)
  • SmartStore.Shipping - Shipping plugin (SDK-style .NET 8)
  • SmartStore.DevTools - Development tools plugin (SDK-style .NET 8)

Architecture Modifications

  • 🔄 Converted from packages.config to PackageReference format
  • 🔄 Migrated from .NET Framework 4.7.2 to .NET 8 target framework
  • 🔄 Removed legacy NuGet.targets and WebApplication.targets dependencies
  • ⚠️ Disabled NuGet.Core packaging infrastructure (incompatible)
  • ⚠️ Disabled legacy test fake classes (System.Web dependent)

🛠️ Tools Used

Microsoft .NET SDK

  • 📦 .NET SDK 8.0.415 - Target runtime and compilation toolchain
  • 🔨 MSBuild 17.0+ - Project build system

Migration Assistants

  • 🤖 Microsoft Upgrade Assistant 0.5.1073 - Attempted automated project upgrades (encountered legacy project format issues)
  • 📋 Manual migration patterns - Applied systematic transformations based on migration knowledge base

Amazon Q Developer

  • 🧠 Model: Claude 3.5 Sonnet v2
  • 💻 Interface: Amazon Q CLI (q chat)
  • 📚 Knowledge Base: Custom .NET migration patterns (24 specialized modules)
  • Capabilities: Automated code analysis, batch file transformations, systematic error resolution

💻 Code Changes

Pre-Build Cleanup (Mandatory First Step)

  • 🗑️ Removed 136 [Index] attributes from entity classes (EF6 → EF Core incompatibility)
  • 🗑️ Removed [PreApplicationStartMethod] attributes (System.Web.PreApplicationStartMethod)
  • 🗑️ Removed [AllowHtml] attributes (System.Web.Mvc.AllowHtmlAttribute)
  • 🔄 Replaced 50+ using statements (System.Web.* → Microsoft.AspNetCore.*)

Project File Transformations

<!-- Before: Legacy .NET Framework format -->  
<Project ToolsVersion="15.0" DefaultTargets="Build">  
  <PropertyGroup>  
    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>  
  </PropertyGroup>  
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />  
</Project>  
  
<!-- After: SDK-style .NET 8 format -->  
<Project Sdk="Microsoft.NET.Sdk">  
  <PropertyGroup>  
    <TargetFramework>net8.0</TargetFramework>  
    <Nullable>disable</Nullable>  
    <ImplicitUsings>disable</ImplicitUsings>  
  </PropertyGroup>  
</Project>  

Package Upgrades

  • ⬆️ Autofac 5.2.0 → 8.0.0
  • ⬆️ Entity Framework 6.4.4 → EF Core 8.0.1
  • ⬆️ AngleSharp 0.9.11 → 1.1.0
  • ⬆️ HtmlSanitizer 4.0.205 → 8.1.870
  • ⬆️ Newtonsoft.Json 13.0.1 → 13.0.3
  • ⬆️ log4net 2.0.8 → 2.0.17
  • Added: Microsoft.AspNetCore.Identity 2.2.0
  • Added: Microsoft.Extensions.Caching.Memory 8.0.1
  • Added: System.ServiceModel.Syndication 8.0.0
  • Added: LigerShark.WebOptimizer.Core 3.0.422
  • Removed: NuGet.Core 2.14.0 (incompatible)
  • Removed: Autofac.Mvc5 5.0.0 (replaced with Autofac.Extensions.DependencyInjection 9.0.0)

Namespace Replacements (Automated)

// System.Web → Microsoft.AspNetCore  
using System.Web.Mvc;using Microsoft.AspNetCore.Mvc;  
using System.Web.Http;using Microsoft.AspNetCore.Mvc;  
using System.Web.Routing;using Microsoft.AspNetCore.Routing;  
using System.Web.Security;using Microsoft.AspNetCore.Identity;  
using System.Web.Optimization;using WebOptimizer;  
using System.Web.Caching;using Microsoft.Extensions.Caching.Memory;  
  
// Entity Framework 6 → EF Core  
using System.Data.Entity;using Microsoft.EntityFrameworkCore;  
using System.Data.Entity.Infrastructure;using Microsoft.EntityFrameworkCore.Infrastructure;  
  
// AngleSharp API updates  
using AngleSharp.Parser.Html;using AngleSharp.Html.Parser;  
using AngleSharp.Extensions;using AngleSharp.Dom;  
  
// HtmlSanitizer namespace  
using Ganss.XSS;using Ganss.Xss;  

Code Disabled (Requires Manual Migration)

  • 🚫 Packaging/ directory (36 NuGet.Core dependent files)
  • 🚫 Fakes/ directory (10 System.Web test fake classes)
  • 🚫 Legacy HTTP modules and handlers (System.Web.IHttpModule)
  • 🚫 Global.asax application events (requires Program.cs migration)

⏱️ Time Savings Estimate

Automated Work Completed

  • 🤖 Project file conversions: 10 projects × 30 min = 5 hours
  • 🤖 Package reference updates: 50+ packages × 5 min = 4 hours
  • 🤖 Attribute removal: 136 attributes × 2 min = 4.5 hours
  • 🤖 Using statement replacements: 200+ files × 3 min = 10 hours
  • 🤖 Namespace analysis and planning: 2 hours

Total Automated Savings: ~25.5 hours

Manual Work Remaining

  • ⚠️ HttpContext type replacements: 68 occurrences × 10 min = 11 hours
  • ⚠️ EF6 to EF Core conversions: 8 DbEntityEntry + mappings = 8 hours
  • ⚠️ Cache infrastructure migration: 14 occurrences × 15 min = 3.5 hours
  • ⚠️ Autofac.Integration removal: 6 occurrences × 20 min = 2 hours
  • ⚠️ Controller/View updates: 50+ controllers × 30 min = 25 hours
  • ⚠️ Program.cs/Startup.cs creation: 4 hours
  • ⚠️ Web.config → appsettings.json: 3 hours
  • ⚠️ Testing and validation: 20 hours

Estimated Remaining Effort: ~76.5 hours

ROI Analysis

  • Foundation work automated: 25% of total migration effort
  • ⚠️ Complex transformations require human expertise: 75% remaining
  • 💡 Knowledge base accelerates remaining work: Reduces manual effort by ~30%

🎯 Next Steps

Immediate Actions (Critical Path)

  1. 🔴 Replace HttpContextBase/HttpRequestBase throughout codebase

    • Use IHttpContextAccessor for dependency injection
    • Replace HttpContext.Current with injected HttpContext
    • Update 68+ occurrences across Core, Services, and Web projects
  2. 🔴 Migrate Entity Framework 6 to EF Core

    • Replace DbEntityEntry with EntityEntry
    • Convert DbSet<T> operations to EF Core equivalents
    • Update all entity mappings from EntityTypeConfiguration to Fluent API
    • Migrate 200+ migration files
  3. 🔴 Replace System.Web.Caching with IMemoryCache

    • Inject IMemoryCache via constructor
    • Replace Cache.Insert() with _cache.Set()
    • Convert CacheDependency to IChangeToken
  4. 🟡 Create ASP.NET Core startup infrastructure

    • Create Program.cs with minimal hosting model
    • Migrate Global.asax logic to middleware pipeline
    • Configure services (DI, MVC, Identity, etc.)
  5. 🟡 Convert configuration system

    • Migrate Web.config to appsettings.json
    • Update configuration access from ConfigurationManager to IConfiguration
    • Migrate connection strings and app settings

Validation Steps

  • Build validation: dotnet build SmartStoreNET.Minimal.sln (currently 286+ errors)
  • Package restore: Verify all NuGet packages resolve correctly
  • ⚠️ Unit test migration: Update test projects to use WebApplicationFactory
  • ⚠️ Integration testing: Validate HTTP pipeline and middleware
  • ⚠️ Database migration: Test EF Core migrations against existing schema
  • ⚠️ Performance testing: Compare .NET 8 vs .NET Framework benchmarks

Improvement Recommendations

  1. 💡 Incremental migration strategy

    • Migrate one project at a time (Core → Data → Services → Web)
    • Maintain .NET Framework compatibility during transition
    • Use multi-targeting (<TargetFrameworks>net472;net8.0</TargetFrameworks>)
  2. 💡 Leverage .NET Upgrade Assistant

    • Fix legacy project format issues first
    • Run upgrade-assistant in analyze mode for guidance
    • Apply automated transformations where possible
  3. 💡 Modernize architecture

    • Replace Autofac with native DI where feasible
    • Remove NuGet.Core packaging (use NuGet.Protocol if needed)
    • Adopt minimal APIs for new endpoints
    • Implement health checks and observability
  4. 💡 Documentation and training

    • Document breaking changes for development team
    • Create migration runbook for similar projects
    • Train team on ASP.NET Core patterns and best practices

📈 Migration Status

Category Status Progress
Project Files ✅ Complete 100% (10/10)
Package Updates ✅ Complete 100%
Pre-Build Cleanup ✅ Complete 100%
System.Web Migration 🟡 In Progress 30%
EF6 → EF Core 🔴 Not Started 0%
Controllers/Views 🔴 Not Started 0%
Configuration 🔴 Not Started 0%
Testing 🔴 Not Started 0%
Overall 🟡 Foundation Complete ~25%

🏁 Conclusion

The migration has successfully established the foundational infrastructure for .NET 8 compatibility, including modern project formats, updated packages, and systematic cleanup of incompatible attributes. However, the application requires significant additional work to achieve a fully functional .NET 8 build. The remaining effort focuses on replacing System.Web dependencies, migrating Entity Framework 6 to EF Core, and modernizing the application startup pipeline. With the knowledge base and automated tooling in place, the remaining work can be completed systematically over an estimated 76.5 hours of focused development effort.

Recommendation: Proceed with incremental migration, prioritizing the Core and Data projects first to establish a stable foundation before tackling the Web layer.


Report generated: Sunday, November 2, 2025
Migration tool: Amazon Q Developer CLI with Claude 3.5 Sonnet v2
Project: SmartStoreNET → .NET 8 Upgrade

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