Migrating a working app to a new platform is usually a significant amount of work. The move from ASP.NET MVC 5 to Core MVC is much different than migrating previous versions of MVC applications (e.g. migrating from to MVC 5). In this video, learn the pros and cons of migrating an MVC 5 application to Core MVC, and the factors that should be considered before deciding to make the move.
- [Voiceover] Before migrating an MVC 5 app to Core MVC, there are some things your should consider. So why should you migrate to Core MVC? Well, first and foremost, you're going to want to take advantage of the Core MVC new features, such as tag helpers, view components, built-in dependency injection, and lots of other improvements in the framework. Maybe you have a performance issue and you want to leverage the increased performance of .NET Core. Now I'm not going to quote numbers here, because all of the studies seem to be catered to a specific test.
But I can tell you anecdotally, my customers that I have taken from MVC 5 to Core MVC have noticed a significant improvement in performance, without significantly changing their code base. Maybe you want to deploy on non-Windows operating systems. Prior to Core MVC and ASP.NET Core, you could not deploy anywhere but Windows, because of the type coupling with system.web. Core MVC and ASP.NET Core will run on Linux and other non-Windows platforms, which could find a significant cost savings for your data center.
Another issue you might be having is keeping libraries and frameworks current. For MVC 5, unless you're going to manually pull in something like Gulp, or Grunt, or Webpack, keeping libraries current meant downloading them from the website, for example, jQuery, and copying them into your project. And then there's the views themselves. There's way too much intermingling between HTML and Razor. And then there's configuration for environment changes. Now certainly, with ASP.NET and MVC 5, you could have different web configs based on your deployment, but leveraging that was a little bit tricky and took some learning to get going.
Core MVC makes it very, very simple to change a configuration based on what environment the application is running in. Well, why should you not migrate? Well, if what you have is working well, then it's really hard to justify to the business rewriting an application, just because there's something shiny and new. Now, we call that resume-driven development, and it happens, but you really want to consider what's best for the business. Maybe you have a very tight release schedule, and you don't have time, based on the business needs, to do a rewrite, while you're still trying to make your commitments.
Maybe your application is significantly complex. That's a whole other issue. But, if it's a very, very complex app, supporting it, let alone migrating it, can be very difficult. And it could be your personnel, maybe you don't have enough. Maybe you have junior developers who, you know, are just now learning MVC 5. Whatever the reason is, you don't have the personnel to move to Core MVC. And then, you also have to take into account the corporate plans for software development.
Maybe your company plans to switch to Java, or some other technology. So, all these things should be considered before you undertake migrating from MVC 5 to Core MVC.
Phil Japikse begins by showing how to install and update the .NET Core SDK. He reviews the functionality of the MVC 5 app, explains how to create necessary projects, and discusses migrating static content. Next, he demonstrates how to create a data access layer, complete the server-side migration, set up the HTTP pipeline, add custom items into the dependency injection container, leverage the new project configuration system, and migrate the controllers. Phil then introduces Tag Helpers—one the big new features in ASP.NET Core—and uses them to migrate and simplify the views. Phil also demonstrates how to create and use custom Tag Helpers. To wrap up, he covers working with view components, explaining what they are and why they're helpful. He walks through how to create the server-side view component code, and how to refactor your app and invoke the view component.
- Reviewing the MVC 5 application
- Creating the data access layer
- Adding and updating the models
- Updating the database
- Completing the server-side migration
- Configuring the HTTP pipeline
- Configuring and using dependency injection
- Migrating the views
- Creating view components