<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pedro Ávila</title>
    <description>The latest articles on DEV Community by Pedro Ávila (@pedro_vila_99b529625617e).</description>
    <link>https://dev.to/pedro_vila_99b529625617e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3142928%2F92e6f7af-bbfa-4c57-a600-ef2308b185e7.jpg</url>
      <title>DEV Community: Pedro Ávila</title>
      <link>https://dev.to/pedro_vila_99b529625617e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pedro_vila_99b529625617e"/>
    <language>en</language>
    <item>
      <title>From .NET Framework 4.8 to .NET 10: What the Tool Did, What I Did, and What My Architecture Saved Me</title>
      <dc:creator>Pedro Ávila</dc:creator>
      <pubDate>Thu, 19 Nov 2026 14:33:12 +0000</pubDate>
      <link>https://dev.to/pedro_vila_99b529625617e/from-net-framework-48-to-net-10-what-the-tool-did-what-i-did-and-what-my-architecture-saved-57d3</link>
      <guid>https://dev.to/pedro_vila_99b529625617e/from-net-framework-48-to-net-10-what-the-tool-did-what-i-did-and-what-my-architecture-saved-57d3</guid>
      <description>&lt;p&gt;I recently migrated a reference project of mine — a Customer API built with hexagonal&lt;br&gt;
architecture and CQRS — from .NET Framework 4.8 to .NET 10. I used the&lt;br&gt;
&lt;a href="https://dotnet.microsoft.com/en-us/platform/upgrade-assistant" rel="noopener noreferrer"&gt;.NET Upgrade Assistant&lt;/a&gt;&lt;br&gt;
for part of the work, did the rest by hand, and ended up with a result I can prove with git:&lt;br&gt;
&lt;strong&gt;the domain and application layers did not change a single byte.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is an honest account of that migration: what the tool actually did, what it could not do,&lt;br&gt;
and why decisions I made before starting mattered more than the tool itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upgrade Assistant converted the class libraries: SDK-style projects, &lt;code&gt;PackageReference&lt;/code&gt;, new TFM.&lt;/li&gt;
&lt;li&gt;It cannot rewrite &lt;code&gt;System.Web&lt;/code&gt;. I rebuilt the host as a new ASP.NET Core project.&lt;/li&gt;
&lt;li&gt;Entities, ports, DTOs and use-case handlers: byte-for-byte identical (same git blob hashes).&lt;/li&gt;
&lt;li&gt;I deleted ~150 lines of DI plumbing, a custom &lt;code&gt;ILogger&lt;/code&gt;, a custom &lt;code&gt;ProblemDetails&lt;/code&gt;,
and 8 binding redirects.&lt;/li&gt;
&lt;li&gt;My own &lt;code&gt;netstandard2.0&lt;/code&gt; NuGet packages came along for free.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The starting point
&lt;/h2&gt;

&lt;p&gt;The solution has seven projects, organised by layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example.Api                  → ASP.NET Web API 2 host (net48)
Example.Dtos                 → commands, queries, results
Example.UseCase              → CQRS handlers + FluentValidation validators
Example.Entities             → domain entities
Example.Ports                → repository interfaces
Example.Adapters             → Dapper implementation
Infraestructure/
  Example.BuildingBlocks     → CQRS contracts, pipeline behaviours, exceptions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The mediator is &lt;a href="https://www.nuget.org/packages/PAN.Mediator" rel="noopener noreferrer"&gt;PAN.Mediator&lt;/a&gt;, a lightweight&lt;br&gt;
library I wrote myself, and data access uses Dapper plus&lt;br&gt;
&lt;a href="https://www.nuget.org/packages/PAN.DapperLambdaSQL" rel="noopener noreferrer"&gt;PAN.DapperLambdaSQL&lt;/a&gt; for lambda-based&lt;br&gt;
queries and partial updates.&lt;/p&gt;

&lt;p&gt;The legacy host had the full &lt;code&gt;System.Web&lt;/code&gt; ceremony: &lt;code&gt;Global.asax&lt;/code&gt;, an &lt;code&gt;App_Start&lt;/code&gt; folder with&lt;br&gt;
five configuration classes, &lt;code&gt;Web.config&lt;/code&gt; with transforms, and &lt;code&gt;packages.config&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Why .NET 10? It is an LTS release (supported until November 2028), and everything I had been&lt;br&gt;
simulating on net48 — dependency injection, logging, ProblemDetails — is built in.&lt;/p&gt;
&lt;h2&gt;
  
  
  The preparation nobody talks about
&lt;/h2&gt;

&lt;p&gt;Here is the part most migration posts skip: &lt;strong&gt;the legacy code already had a modern shape.&lt;/strong&gt;&lt;br&gt;
Before touching the TFM, the net48 project was already using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Microsoft.Extensions.DependencyInjection&lt;/code&gt; (yes, on .NET Framework),&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ILogger&amp;lt;T&amp;gt;&lt;/code&gt; abstractions, backed by a tiny &lt;code&gt;TraceLogger&lt;/code&gt; adapter over &lt;code&gt;System.Diagnostics.Trace&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;a mediator library targeting &lt;code&gt;netstandard2.0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the application core did not depend on &lt;code&gt;System.Web&lt;/code&gt; at all. The migration was about&lt;br&gt;
replacing the &lt;em&gt;host&lt;/em&gt;, not the &lt;em&gt;application&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson: modernise your abstractions before you migrate.&lt;/strong&gt; Every &lt;code&gt;System.Web&lt;/code&gt; dependency&lt;br&gt;
you remove beforehand is one less thing to rewrite later.&lt;/p&gt;
&lt;h2&gt;
  
  
  What Upgrade Assistant actually did
&lt;/h2&gt;

&lt;p&gt;For the six class libraries, the tool did the mechanical work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Converted old-style csproj files to SDK-style.&lt;/li&gt;
&lt;li&gt;Replaced &lt;code&gt;packages.config&lt;/code&gt; with &lt;code&gt;PackageReference&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Changed the target framework to &lt;code&gt;net10.0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Moved &lt;code&gt;AssemblyInfo.cs&lt;/code&gt; attributes into MSBuild properties (all seven &lt;code&gt;AssemblyInfo.cs&lt;/code&gt;
files are gone).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see the tool's fingerprint in the converted project file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Before: 14 KB of MSBuild ceremony, HintPaths to ..\packages\..., packages.config --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;TargetFrameworkVersion&amp;gt;&lt;/span&gt;v4.8&lt;span class="nt"&gt;&amp;lt;/TargetFrameworkVersion&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Reference&lt;/span&gt; &lt;span class="na"&gt;Include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"FluentValidation"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;HintPath&amp;gt;&lt;/span&gt;..\packages\FluentValidation.11.12.0\lib\netstandard2.0\FluentValidation.dll&lt;span class="nt"&gt;&amp;lt;/HintPath&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Reference&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- After: Example.BuildingBlocks.csproj, the whole file --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Project&lt;/span&gt; &lt;span class="na"&gt;Sdk&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Microsoft.NET.Sdk"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TargetFramework&amp;gt;&lt;/span&gt;net10.0&lt;span class="nt"&gt;&amp;lt;/TargetFramework&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;AssemblyTitle&amp;gt;&lt;/span&gt;Example.BuildingBlocks&lt;span class="nt"&gt;&amp;lt;/AssemblyTitle&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Product&amp;gt;&lt;/span&gt;Example.BuildingBlocks&lt;span class="nt"&gt;&amp;lt;/Product&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;AssemblyVersion&amp;gt;&lt;/span&gt;1.0.0.0&lt;span class="nt"&gt;&amp;lt;/AssemblyVersion&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;FrameworkReference&lt;/span&gt; &lt;span class="na"&gt;Include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Microsoft.AspNetCore.App"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;PackageReference&lt;/span&gt; &lt;span class="na"&gt;Include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"FluentValidation"&lt;/span&gt; &lt;span class="na"&gt;Version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"12.2.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;PackageReference&lt;/span&gt; &lt;span class="na"&gt;Include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"PAN.Mediator"&lt;/span&gt; &lt;span class="na"&gt;Version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"2.0.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those &lt;code&gt;AssemblyTitle&lt;/code&gt;/&lt;code&gt;Product&lt;/code&gt; properties used to live in &lt;code&gt;AssemblyInfo.cs&lt;/code&gt;. That is the&lt;br&gt;
tool's signature, and it is a good thing: less ceremony, same metadata.&lt;/p&gt;
&lt;h2&gt;
  
  
  What the tool could not do
&lt;/h2&gt;

&lt;p&gt;The Upgrade Assistant does not migrate &lt;code&gt;System.Web&lt;/code&gt; namespaces —&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/migration/fx-to-core/" rel="noopener noreferrer"&gt;Microsoft's migration guide&lt;/a&gt;&lt;br&gt;
is explicit about it. ASP.NET Core is a different hosting model, not a new version of Web API.&lt;/p&gt;

&lt;p&gt;So I created a new project, &lt;code&gt;Example.ApiCore&lt;/code&gt; (&lt;code&gt;Microsoft.NET.Sdk.Web&lt;/code&gt;), moved the controller&lt;br&gt;
over, and deleted the old host entirely:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Legacy (net48)&lt;/th&gt;
&lt;th&gt;Modern (net10)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Global.asax&lt;/code&gt; + &lt;code&gt;App_Start&lt;/code&gt; (5 classes)&lt;/td&gt;
&lt;td&gt;One &lt;code&gt;Program.cs&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;IDependencyResolver&lt;/code&gt; bridge (~50 lines)&lt;/td&gt;
&lt;td&gt;Built-in container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Controllers registered by reflection&lt;/td&gt;
&lt;td&gt;Registered automatically&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validators registered by reflection&lt;/td&gt;
&lt;td&gt;&lt;code&gt;AddValidatorsFromAssemblyContaining&amp;lt;T&amp;gt;()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;ConfigurationManager&lt;/code&gt; + env fallback&lt;/td&gt;
&lt;td&gt;&lt;code&gt;IConfiguration&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Web.config&lt;/code&gt; + transforms&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;appsettings.json&lt;/code&gt; + user-secrets&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The composition root is where the difference hurts most. Before, &lt;code&gt;MediatorConfig&lt;/code&gt; built a&lt;br&gt;
service provider manually, wired a custom dependency resolver, and replaced Web API's&lt;br&gt;
exception handler by hand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Before: MediatorConfig.cs (excerpt)&lt;/span&gt;
&lt;span class="nc"&gt;ServiceProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BuildServiceProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;GlobalConfiguration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DependencyResolver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WebApiDependencyResolver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ServiceProvider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;GlobalConfiguration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IExceptionHandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;ServiceProvider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetRequiredService&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CustomExceptionHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ...plus a foreach loop registering every IHttpController in DI&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// After: Program.cs (excerpt)&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPanMediator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RegisterServicesFromAssembly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CreateCustomerUseCaseHandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Assembly&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddOpenBehavior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ValidationBehavior&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddOpenBehavior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;LoggingBehavior&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddValidatorsFromAssemblyContaining&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CreateCustomerCommandValidator&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddScoped&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ICustomerRepository&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CustomerRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;connectionString&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddExceptionHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CustomExceptionHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddProblemDetails&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddControllers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;UseExceptionHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MapControllers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Around 150 lines of plumbing across two files became roughly 15. The static&lt;br&gt;
&lt;code&gt;ServiceProvider&lt;/code&gt; property (a service locator in disguise) simply disappeared.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;IExceptionHandler&lt;/code&gt;: same name, two worlds
&lt;/h2&gt;

&lt;p&gt;This was my favourite trap. Both frameworks have an &lt;code&gt;IExceptionHandler&lt;/code&gt;, but they are&lt;br&gt;
different contracts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Web API 2: System.Web.Http.ExceptionHandling&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt; &lt;span class="nc"&gt;HandleAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ExceptionHandlerContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// ASP.NET Core: Microsoft.AspNetCore.Diagnostics&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ValueTask&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;TryHandleAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;exception&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same name, different namespace, different signature, different wiring&lt;br&gt;
(&lt;code&gt;AddExceptionHandler&amp;lt;T&amp;gt;()&lt;/code&gt; + &lt;code&gt;AddProblemDetails()&lt;/code&gt; + &lt;code&gt;UseExceptionHandler()&lt;/code&gt; instead of&lt;br&gt;
&lt;code&gt;Services.Replace&lt;/code&gt;). If you migrate on autopilot, the compiler will tell you — but only&lt;br&gt;
after you understand &lt;em&gt;why&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The payoff: two custom classes were deleted.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;My hand-rolled &lt;code&gt;ProblemDetails&lt;/code&gt; → &lt;code&gt;Microsoft.AspNetCore.Mvc.ProblemDetails&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;My &lt;code&gt;TraceLogger&amp;lt;T&amp;gt;&lt;/code&gt; adapter → the framework's real logging providers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final handler maps exceptions to RFC 7807 responses with a switch expression, and&lt;br&gt;
&lt;code&gt;traceId&lt;/code&gt; comes free from &lt;code&gt;HttpContext.TraceIdentifier&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nc"&gt;Detail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nc"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nc"&gt;StatusCode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;exception&lt;/span&gt; &lt;span class="k"&gt;switch&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;ValidationException&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exception&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;nameof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ValidationException&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Status400BadRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;BusinessException&lt;/span&gt; &lt;span class="n"&gt;business&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;business&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Error de negocio"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;business&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Status&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;business&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Status&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Status400BadRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Ocurrió un error inesperado en nuestro sistema."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Internal Server Error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;StatusCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Status500InternalServerError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And those 8 &lt;code&gt;&amp;lt;bindingRedirect&amp;gt;&lt;/code&gt; entries in &lt;code&gt;Web.config&lt;/code&gt;? Gone. ASP.NET Core resolves&lt;br&gt;
assembly versions at build time. No more DLL hell at runtime.&lt;/p&gt;
&lt;h2&gt;
  
  
  The proof: git says the core never changed
&lt;/h2&gt;

&lt;p&gt;This is the part I am most proud of, and you can verify it yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff master feature/migrate-to-net10 -- Example.UseCase Example.Dtos Example.Entities Example.Ports
&lt;span class="c"&gt;# empty output&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The four use-case handlers, the DTOs, the entity, the repository port, the logging behaviour&lt;br&gt;
and the CQRS contracts have &lt;strong&gt;identical blob hashes in both branches&lt;/strong&gt;. Not "similar".&lt;br&gt;
Identical.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Before (net48)&lt;/th&gt;
&lt;th&gt;After (net10)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;API project file&lt;/td&gt;
&lt;td&gt;~14 KB&lt;/td&gt;
&lt;td&gt;~1 KB (−93%)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Packages in the host&lt;/td&gt;
&lt;td&gt;22 (&lt;code&gt;packages.config&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;3 (&lt;code&gt;PackageReference&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuration&lt;/td&gt;
&lt;td&gt;64-line &lt;code&gt;Web.config&lt;/code&gt;, 8 binding redirects&lt;/td&gt;
&lt;td&gt;12-line &lt;code&gt;appsettings.json&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DI plumbing&lt;/td&gt;
&lt;td&gt;~150 lines&lt;/td&gt;
&lt;td&gt;~15 lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom infra classes&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;TraceLogger&lt;/code&gt;, &lt;code&gt;ProblemDetails&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;deleted (built-in)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Domain/application files changed&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That is the hexagonal architecture paying for itself. The tool migrated my project files;&lt;br&gt;
the architecture migrated my system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependencies: the upgrade you didn't know you needed
&lt;/h2&gt;

&lt;p&gt;Migrating the TFM also unlocked versions I could not use before:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FluentValidation 11.12.0 → 12.2.0.&lt;/strong&gt; Version 12
&lt;a href="https://docs.fluentvalidation.net/en/latest/upgrading-to-12.html" rel="noopener noreferrer"&gt;dropped netstandard2.0 support&lt;/a&gt;,
so net48 silently pinned me to 11.x. Your legacy TFM does not just age your runtime —
it ages your whole dependency tree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;System.Data.SqlClient&lt;/code&gt; → &lt;code&gt;Microsoft.Data.SqlClient&lt;/code&gt; 7.1.2.&lt;/strong&gt; Classic gotcha: encryption
is on by default since 4.0, so local connections need &lt;code&gt;TrustServerCertificate=True&lt;/code&gt;
(or a proper certificate). My connection string already had it, but plan for this.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dapper 2.0.78 → 2.1.89.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PAN.Mediator 2.0.0 and PAN.DapperLambdaSQL 1.3.0: unchanged.&lt;/strong&gt; Both target
&lt;code&gt;netstandard2.0&lt;/code&gt;, so they run on net48 and net10 without recompiling. If you maintain
libraries, this is the argument for netstandard2.0 in one sentence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bonus: the modern host got Swagger (Swashbuckle) in development — something the legacy&lt;br&gt;
API never had.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Rewrites lose defensive details.&lt;/strong&gt; My legacy handler had a guard:
&lt;code&gt;Status &amp;gt; 0 ? ... : BadRequest&lt;/code&gt;, because &lt;code&gt;BusinessException&lt;/code&gt; leaves &lt;code&gt;Status = 0&lt;/code&gt; when
constructed with just a message. My first migrated version dropped it — and a
&lt;code&gt;BusinessException("msg")&lt;/code&gt; would have set &lt;code&gt;StatusCode = 0&lt;/code&gt; and thrown &lt;em&gt;inside the
exception handler&lt;/em&gt;. A post-migration review caught it. Compilation is not behavioural
equivalence: diff the old code against the new, line by line.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Polish the REST details while you are there.&lt;/strong&gt; &lt;code&gt;Created(string.Empty, result)&lt;/code&gt; became
&lt;code&gt;CreatedAtAction(nameof(Single), new { id = result.Id }, result)&lt;/code&gt; — a real &lt;code&gt;Location&lt;/code&gt;
header instead of an empty one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secrets leave the repo.&lt;/strong&gt; The legacy &lt;code&gt;Web.config&lt;/code&gt; had a database password in plain
text. Now the connection string lives in user-secrets / environment variables, and
&lt;code&gt;appsettings.json&lt;/code&gt; ships empty. Rotate anything that ever touched source control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be honest about trade-offs.&lt;/strong&gt; &lt;code&gt;Example.BuildingBlocks&lt;/code&gt; now takes a
&lt;code&gt;FrameworkReference&lt;/code&gt; to &lt;code&gt;Microsoft.AspNetCore.App&lt;/code&gt; (it used to reference &lt;code&gt;System.Web.Http&lt;/code&gt;).
A purist would move the exception handler into the host; I keep it centralised for reuse.
Know which rules you are bending and why.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Closing
&lt;/h2&gt;

&lt;p&gt;The whole migration took a few hours of manual work on top of the tool's output, and the&lt;br&gt;
risk was low because the core was already isolated. If your domain is coupled to&lt;br&gt;
&lt;code&gt;System.Web&lt;/code&gt;, no tool will save you. If it is not, the tool plus a new host is enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The repo, with both branches so you can diff the whole thing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Legacy (net48): &lt;code&gt;master&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Migrated (net10): &lt;code&gt;feature/migrate-to-net10&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Full diff: &lt;a href="https://github.com/PedroAvila/LegacyProject/compare/master...feature/migrate-to-net10" rel="noopener noreferrer"&gt;https://github.com/PedroAvila/LegacyProject/compare/master...feature/migrate-to-net10&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/PedroAvila/LegacyProject" rel="noopener noreferrer"&gt;https://github.com/PedroAvila/LegacyProject&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are planning a similar migration, start by asking one question: &lt;em&gt;how much of my code&lt;br&gt;
would survive if I deleted the host today?&lt;/em&gt; That number is your real migration cost.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>dotnet</category>
      <category>refactoring</category>
      <category>softwareengineering</category>
    </item>
  </channel>
</rss>
