🚀 Upgrade ContosoUniversity from .NET Framework 4.8 to .NET 8.0#5
Open
barea1 wants to merge 16 commits intoAzure-Samples:mainfrom
Open
🚀 Upgrade ContosoUniversity from .NET Framework 4.8 to .NET 8.0#5barea1 wants to merge 16 commits intoAzure-Samples:mainfrom
barea1 wants to merge 16 commits intoAzure-Samples:mainfrom
Conversation
added 16 commits
October 30, 2025 18:16
Converted ContosoUniversity project from ASP.NET MVC (.NET Framework) to ASP.NET Core targeting net8.0. Updated project file to use SDK-style format and PackageReference for dependencies, removing packages.config and legacy assembly references. Deleted obsolete files including Global.asax, PaginatedList.cs, LoggingService.cs, and .gitkeep for TeachingMaterials. Simplified Program.cs to use SystemWebAdapters for session and application management, removing custom database initialization and notification service registration. Cleaned up appsettings.json by removing connection strings and notification queue path. Updated launchSettings.json with new ports. Overall, modernized the project structure and removed unused or incompatible components.
Upgraded multiple NuGet package references in ContosoUniversity.csproj to their latest versions, including Entity Framework Core (from 3.1.32 to 8.0.21), Microsoft.Data.SqlClient, Microsoft.Extensions.* libraries, and Newtonsoft.Json. Removed obsolete .NET Framework references and packages such as NETStandard.Library, System.Messaging, and Antlr (replaced with Antlr4). Added new packages: Microsoft.AspNetCore.SystemWebAdapters, Antlr4, and System.Configuration.ConfigurationManager to support updated framework features. This modernizes the project for .NET 8.0 compatibility and improves security and performance.
Upgraded the Microsoft.Data.SqlClient.SNI.runtime package from version 2.1.1 to 6.0.2 in ContosoUniversity.csproj to ensure compatibility and access to the latest features and fixes.
Replaced System.Web.Mvc and related namespaces with Microsoft.AspNetCore.Mvc across all controllers and configuration files. Updated controller actions to use ASP.NET Core conventions, such as StatusCodeResult and NotFound, and changed model binding syntax. Removed legacy configuration files (Web.config, AssemblyInfo.cs) and added assembly metadata to the .csproj file. Added a note in BundleConfig about bundling changes in ASP.NET Core. Cleaned up unused using statements and adjusted project structure for .NET 8.0 compatibility.
…pleted: replaced all @Scripts.Render and @Styles.Render with direct tags, removed BundleConfig and related references
…added to Program.cs using app.MapControllerRoute
…Current.Server.MapPath' to resolve CS0103. The Server property is accessible via System.Web.HttpContext.Current in the current framework using the SystemWebAdapters package. Línea 177: Replaced 'Server.MapPath' with 'System.Web.HttpContext.Current.Server.MapPath' to resolve CS0103. The Server property is accessible via System.Web.HttpContext.Current in the current framework using the SystemWebAdapters package. Línea 234: Replaced 'Server.MapPath' with 'System.Web.HttpContext.Current.Server.MapPath' to resolve CS0103. The Server property is accessible via System.Web.HttpContext.Current in the current framework using the SystemWebAdapters package. Línea 81: Replaced 'Server.MapPath' with 'System.Web.HttpContext.Current.Server.MapPath' to resolve CS0103. The Server property is accessible via System.Web.HttpContext.Current in the current framework using the SystemWebAdapters package.' en el archivo 'ContosoUniversity\Controllers\CoursesController.cs'
…e namespace does not exist in the project dependencies. The MessageQueue type is not available in .NET 8.0 and no direct replacement is found in the current project context. Further investigation is needed to determine a suitable cross-platform messaging solution, such as Azure Service Bus or RabbitMQ, but this change addresses the immediate compilation error.' en el archivo 'ContosoUniversity\Services\NotificationService.cs'
…m.Messaging is not present. The code must be refactored to use a supported messaging system. A comment is added to indicate the required migration.' en el archivo 'ContosoUniversity\Services\NotificationService.cs'
…available in .NET 8.0 and alternatives should be considered. No code fix is possible as MessageQueue and System.Messaging are not available in .NET 8.0.' en el archivo 'ContosoUniversity\Services\NotificationService.cs'
- Successfully upgraded from .NET Framework 4.8 to .NET 8.0 - Converted project to SDK-style format - Updated all NuGet packages to .NET 8.0 compatible versions - Migrated System.Web.Optimization to direct HTML tags - Migrated RouteCollection to app.MapControllerRoute - Migrated GlobalFilterCollection to middleware - Migrated Global.asax.cs to Program.cs - Temporarily disabled MSMQ (System.Messaging) - requires modern messaging solution - Fixed all compilation errors - Added Azure deployment scripts and configurations: * deploy-to-azure.ps1 (PowerShell deployment script) * azure-deploy.json (ARM template) * azure-deploy.parameters.json (ARM parameters) * .github/workflows/azure-deploy.yml (GitHub Actions CI/CD) * AZURE-DEPLOYMENT-GUIDE.md (Complete deployment guide) - Updated documentation with upgrade report - Project builds successfully and ready for Azure deployment Security fixes: - Microsoft.Data.SqlClient updated to 6.1.2 (CVE-2024-0056) - Microsoft.Identity.Client updated to 4.78.0 Known limitations: - MSMQ functionality disabled (needs replacement with Azure Service Bus/RabbitMQ) - SystemWebAdapters removed (not needed for native .NET 8)
|
@barea1 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Upgrade ContosoUniversity from .NET Framework 4.8 to .NET 8.0
📋 Summary
This PR contains the complete migration of the ContosoUniversity application from .NET Framework 4.8 to .NET 8.0, including all necessary code changes, dependency updates, and Azure deployment configurations.
🎯 Objectives Completed
✅ Project Upgrade
✅ Framework Migrations
✅ Security Fixes
✅ Azure Deployment Ready
✅ Build Status
📦 Major Package Updates
🔄 Code Changes
Controllers
Views
Configuration
Services
📝 Files Added
Deployment Scripts:
deploy-to-azure.ps1- Automated PowerShell deploymentazure-deploy.json- ARM template for infrastructureazure-deploy.parameters.json- ARM parameters.github/workflows/azure-deploy.yml- GitHub Actions CI/CDDocumentation:
AZURE-DEPLOYMENT-GUIDE.md- Complete Azure deployment guide.github/upgrades/dotnet-upgrade-plan.md- Upgrade plan.github/upgrades/dotnet-upgrade-report.md- Upgrade report📝 Files Modified
Project Files:
ContosoUniversity.csproj- SDK-style project, updated dependenciesProgram.cs- New ASP.NET Core 8.0 startupappsettings.json- Added connection strings and configurationControllers:
BaseController.cs- Updated for dependency injectionHomeController.cs- Added ErrorViewModel supportStudentsController.cs- Updated for ASP.NET CoreCoursesController.cs- Updated for ASP.NET CoreInstructorsController.cs- Updated TryUpdateModelAsyncDepartmentsController.cs- Updated for ASP.NET CoreNotificationsController.cs- Removed JsonRequestBehaviorViews:
Views/Shared/_Layout.cshtml- Direct script/style tagsViews/Shared/Error.cshtml- Updated error modelViews/Students/Index.cshtml- Fixed PaginatedList namespaceServices:
Services/NotificationService.cs- DI pattern, MSMQ disabled📝 Files Deleted
App_Start/BundleConfig.cs- No longer neededApp_Start/RouteConfig.cs- Replaced by Program.csApp_Start/FilterConfig.cs- Replaced by middlewareGlobal.asax.cs- Migrated to Program.csWeb.config- Replaced by appsettings.jsonMSMQ / System.Messaging
Status:⚠️ Temporarily Disabled
Reason: System.Messaging is not fully supported in .NET Core/8.0
Recommendation: Implement modern messaging solution:
Files Affected:
Services/NotificationService.cs- Contains TODO commentsSystemWebAdapters
Status: ✅ Removed
Reason: Not needed for native .NET 8.0 applications
Impact: None - application works without it
🧪 Testing
Build Verification
✅ Status: Passing
Manual Testing Recommended
🚀 Deployment Instructions
Quick Deploy to Azure
Option 1: PowerShell Script (Automated)
Option 2: Visual Studio
Option 3: GitHub Actions (CI/CD)
AZURE_WEBAPP_PUBLISH_PROFILEsecretSee
AZURE-DEPLOYMENT-GUIDE.mdfor detailed instructions.💰 Estimated Azure Costs
Development/Testing:
Production:
📚 Documentation
All documentation has been updated:
🔐 Security Considerations
📊 Migration Statistics
✅ Checklist
🙏 Review Notes
Please review:
📞 Support
For questions or issues:
.github/upgrades/dotnet-upgrade-report.mdAZURE-DEPLOYMENT-GUIDE.md🎉 Ready to Merge!
This PR is ready for review and merge. The application:
Recommended Actions After Merge:
Branch:
Refactor-tres→mainAuthor: @barea1
Reviewers: @team (assign as needed)
Labels:
enhancement,migration,.net-8,azure