ASP.NET Core MVC remains a solid choice for building web applications, but what if you want to start using Blazor for some of your projects? How do you migrate from MVC to Blazor and what pitfalls should you look out for along the way?

A Repeatable Process for Migrating from MVC to Blazor

If you’re planning to take an existing MVC app and migrate all (or parts) of it to Blazor, the key is to break this down into smaller steps; you’re going to find it much easier to migrate an app if you do it in stages.

One sustainable approach is to migrate one view at a time.

Say you wanted to take this user list page and migrate it from MVC to Blazor:

User list table

Here’s how I would tackle it:

  1. Copy the existing view’s markup from its .cshtml file to a .razor file.
  2. In the @code section for the new component declare a Model property of the same type as the one the view currently references.
  3. Migrate the code for populating and returning the model (from the controller to the component).

#mvc #blazor #asp.net core

Migrating from ASP.NET Core MVC to Blazor
27.35 GEEK