tweet #tarabica19
Migration from ASP.NET MVC to ASP.NET Core
Belgrade
May 25th, 2019
Miroslav Popović
Technical Lead, Seavus Group
https://miroslavpopovic.com
@miroslavpopovic
Sponzori Generalni sponzor
Srebrni sponzori
Tehnički sponzori
tweet #tarabica19
Bronzani sponzor
Partner konferencije
tweet #tarabica19
Introduction
A bit of history
• .NET Framework 1.0
• ASP.NET 1.0
• ASP.NET 2.0
• ASP.NET MVC
• ASP.NET WebAPI
• ASP.NET Core & .NET Core
tweet #tarabica19
Why migrate?
• Old platform, no longer improved
• .NET Framework 4.8 is the last version
• Performance is not that great
• System.Web dependency
• Windows only
• Using it with containers is harder
• Running multiple side-by-side installations is harder
• Configuration is harder
• Doesn’t play well with modern web
tweet #tarabica19
Why not stay?
tweet #tarabica19
ASP.NET Core benefits
• Multiplatform
• Open source for real
• Performance
• New configuration system
• Easy to use with Docker
tweet #tarabica19
ASP.NET Core benefits (cont.)
• Side by side with another app on different .NET Core
• Joined MVC and WebAPI
• Excellent for REST APIs
• Plays great with modern web tools
• Part of the .NET future
tweet #tarabica19
ASP.NET Core benefits (cont.)
tweet #tarabica19
.NET Standard
tweet #tarabica19
tweet #tarabica19
Migration from ASP.NET MVC
Migration process
• Latest version of .NET Framework (at least 4.6.2)
• Analyze your solution with .NET Portability Analyzer
• Migrate non-ASP.NET projects to .NET Standard
• Create new ASP.NET Core 2.1+ (or 3.0) project
• Migrate startup code and initialization
• Migrate static files, configure bundles
• Migrate views and actions
tweet #tarabica19
Project organization
tweet #tarabica19
Project files
tweet #tarabica19
Middleware pipeline
tweet #tarabica19
Startup
tweet #tarabica19
Razor changes
tweet #tarabica19
Tag helpers and client libs
tweet #tarabica19
Web Components
• Dynamic navigation menus
• Tag cloud (where it queries the database)
• Login panel
• Shopping cart
• Recently published articles
• Sidebar content on a typical blog
tweet #tarabica19
Web API
• Same controllers as for MVC
• Configuration in Startup
• [ApiController]
• ActionResult<T>
• Swagger / Open API specification
• HTTPS by default
• API conventions
• API analyzers
tweet #tarabica19
tweet #tarabica19
Potential problems
.NET Core & .NET Standard
• Not all APIs are migrated to Core
• .NET Portability Analyzer
• Registry access
• WCF servers
• AppDomain
• Remoting
tweet #tarabica19
Database access
• Depends on DB library used
• Direct ADO.NET access
• Micro ORMs
• NHibernate
• Entity Framework
tweet #tarabica19
Entity Framework Core
• Different than EF6.x
• Migrations
• Still not feature-ready
• Entity Framework 6.3 migrated to .NET Core 3.0
tweet #tarabica19
ASP.NET Identity
• Database changes
• View changes
• Scaffolding
tweet #tarabica19
tweet #tarabica19
Closing words
When not to migrate?
• ASP.NET Web Forms
• ASP.NET MVC Web Forms
• Missing APIs
• Old dependencies
• …
• Rewriting parts of solution
tweet #tarabica19
ASP.NET Core future
• .NET Core 3.0 - September 2019.
• Performance++
• Server-side Blazor
• Endpoint routing improvements
• SPA template improvements
• …
• Client-side Blazor
tweet #tarabica19
Current performance
tweet #tarabica19
ASP.NET Core: Saturating 10GbE at 7+ million request/s - https://bit.ly/2Gns2Dq
Future performance
tweet #tarabica19
https://aka.ms/aspnet/benchmarks
6 minutes, 64 connections, 120.000.000 requests
.NET 5!
tweet #tarabica19
Are you convinced?
• Performance, performance
• Features
• some free, some with additional work
• Open-source
• Modern web framework
• Dockerizable
• Future
• …
tweet #tarabica19
Guides and tools
• Migration docs
• https://docs.microsoft.com/en-us/aspnet/core/migration/proper-to-2x/?view=aspnetcore-2.2
• Should, When, and How Can I Migrate to .NET Core – Mitchel Sellers
• https://mitchelsellers.com/blogs/2018/07/19/should-when-and-how-can-i-migrate-to-net-core
• .NET Portability Analyzer
• https://docs.microsoft.com/en-us/dotnet/standard/analyzers/portability-analyzer
• https://github.com/Microsoft/dotnet-apiport
• Migrate project files tool
• https://github.com/hvanbakel/CsprojToVs2017
tweet #tarabica19
Thank you! Questions?
https://miroslavpopovic.com
@miroslavpopovic
Sponzori Generalni sponzor
Srebrni sponzori
Tehnički sponzori
tweet #tarabica19
Bronzani sponzor
Partner konferencije

Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core

Editor's Notes

  • #6 Image downloaded from: https://www.flickr.com/photos/markgregory/15693006019
  • #8 Image downloaded from: https://www.flickr.com/photos/andyhay/8196333166