Skip to content

Modernize SampleMvcWebApp to cross-platform .NET 8 (ASP.NET Core MVC + EF Core 8) - #23

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784048937-net8-migration
Open

Modernize SampleMvcWebApp to cross-platform .NET 8 (ASP.NET Core MVC + EF Core 8)#23
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784048937-net8-migration

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Migrates the app from ASP.NET MVC 5 / .NET Framework 4.5.1 to cross-platform ASP.NET Core MVC on .NET 8, preserving all pages, CRUD flows, and business rules. Every project is now SDK-style net8.0; System.Web, Global.asax, web.config, packages.config, Autofac, and log4net are gone. The solution builds clean (0 warnings) and a net8.0 NUnit 4 suite (17 tests) passes.

The app depends on the GenericServices framework, which is EF6-only with no .NET 8 build. Rather than rewrite every DTO/controller onto a different framework (behavior-risky), this PR ports the exact GenericServices/GenericLibsBase API surface the app uses into two small in-repo net8.0 libraries backed by EF Core 8 + AutoMapper 14, so DTOs and controller call-sites stay essentially unchanged.

Architecture: MVC5 → ASP.NET Core MVC

  • Global.asax + App_Start/* (Route/Bundle/Filter config) → Program.cs (middleware, routing, DI, DB init).
  • Autofac + custom DiModelBinder (which enabled action-parameter service injection like Index(IListService service)) → built-in DI. To keep the original controller signatures unchanged, a small ServiceParameterBindingConvention marks action parameters whose type is a registered service as BindingSource.Services:
    // Program.cs
    builder.Services.AddSingleton<IConfigureOptions<MvcOptions>, ConfigureServiceParameterBinding>();
    // convention: if IServiceProviderIsService.IsService(param.Type) -> BindingSource.Services
  • MVC5 bundling (@Styles.Render/@Scripts.Render) → static <link>/<script> tags served from wwwroot/ (Content, Scripts, fonts moved there).
  • MvcHtmlString error HTML in TempData["errorMessage"] → plain string rendered with @Html.Raw(...) (identical output).
  • log4net → Microsoft.Extensions.Logging via a MelGenericLogger : IGenericLogger bridge wired through GenericLibsBaseConfig.
  • InternalsInfo Windows-only PerformanceCounter → cross-platform GC.GetGCMemoryInfo().
  • web.config/Settingsappsettings.json (connection string + HostTypeString).

Architecture: EF6 → EF Core 8

  • SampleWebAppDb is now an EF Core DbContext implementing IGenericServicesDbContext + IValidateOnSave; default provider is SQLite (Data Source=SampleWebAppDb.db) for cross-platform demo use.
  • Data model preserved: Blog, Post, Tag, Post.BlogId, many-to-many Post/Tag, LastUpdated stamping, XML seed loading, and small/medium reset semantics. Initial EF Core migration added under DataLayer/Migrations.
  • EF6 DbContext.ValidateEntity (no EF Core equivalent) → IValidateOnSave.ValidateEntity, invoked by the ported SaveChangesWithChecking, preserving the unique-tag-slug rule and error text.
  • GenericServices "write" maps: instead of AutoMapper cloning DTO→entity (which would clone/recurse tracked navigations like the chosen Tags), a reflection copier (EntityFromDto) copies scalars and assigns navigations by reference so EF Core tracks them; AutoMapper is used only for entity→DTO reads/projections (ProjectTo).

Changed dependencies (and why)

  • AutoMapper 14.0.0 — last MIT-licensed line (15+ is commercial). A single scoped NuGetAuditSuppress for GHSA-rvv3-g6hj-g44x is applied and documented; no security setting was weakened.
  • EF Core 8 (Microsoft.EntityFrameworkCore.Sqlite/.Design 8.0.11), built-in DI, Microsoft.Extensions.Logging.
  • Tests: NUnit 4.2.2 + NUnit3TestAdapter + Microsoft.NET.Test.Sdk, EF Core SQLite in-memory.

Test evidence

  • dotnet build SampleWebApp.sln0 warnings, 0 errors (Debug + Release).
  • dotnet test SampleWebApp.sln17 passed, 0 failed.
  • Ran the app (dotnet run --project SampleWebApp): DB auto-migrates + seeds; verified 200 for Home, Posts/Tags/Blogs (sync + async), Details, Edit, Create, Internals, CodeView, Delay. Verified a full write path via HTTP with antiforgery token: create Tag → 302 + appears in list; duplicate slug → validation error rendered.
  • New regression tests cover: XML seed counts, many-to-many + blogger load, LastUpdated stamping, list projections/flattening (PostsCount, BloggerName, Tags), detail/edit setup pickers, update (title + tag replacement), create with tags, delete, async detail/create, and business-rule rejections (no blogger, no tags, ! title, duplicate slug).

Remaining risks

  • Default DB provider changed to SQLite (was SQL Server LocalDB); production SQL Server compatibility not re-validated.
  • EF Core validation/tracking/cascade behavior can differ subtly from EF6.
  • AutoMapper pinned to 14.0.0 with a scoped audit suppression (see above).
  • The legacy test suite asserted EF6/Autofac/MVC5 internals that no longer exist; it was replaced with focused regression tests for the preserved behavior rather than ported 1:1.

Human-review checklist

  • Confirm SQLite is acceptable as the demo provider (or swap the UseSqlite call + connection string for SQL Server).
  • Review EntityFromDto navigation-by-reference copy vs. the original AutoMapper write behavior.
  • Review ServiceParameterBindingConvention as the replacement for the MVC5 DiModelBinder.
  • Accept the AutoMapper 14 pin + GHSA-rvv3-g6hj-g44x suppression.
  • Spot-check the new regression tests are meaningful for your acceptance criteria.

Rollback guidance

Single-branch change with no data migration of existing stores (new local SQLite file is created on first run). To roll back, revert the merge commit / redeploy the previous build; delete the generated SampleWebAppDb.db if present. No external infrastructure was modified.

Link to Devin session: https://app.devin.ai/sessions/96f873d8bcf34290ab2609be7b941738
Requested by: @achalc


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

…MVC on .NET 8

- Convert all projects to SDK-style net8.0
- MVC5/System.Web -> ASP.NET Core MVC (Program.cs, middleware, built-in DI)
- EF6 -> EF Core 8 (SQLite, migrations) preserving data model + validation
- In-repo GenericServices/GenericLibsBase compatibility port on EF Core 8 + AutoMapper 14
- Autofac -> built-in DI; log4net -> Microsoft.Extensions.Logging; web.config -> appsettings.json
- Replace legacy NUnit2/.NET4.5 tests with net8.0 NUnit4 regression suite for CRUD/service behavior
- Add GitHub Actions CI for .NET 8 build+test; update README

Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
@achalc achalc self-assigned this Jul 14, 2026
@devin-ai-integration

Copy link
Copy Markdown
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, CI, and merge conflict 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