Easy Steps to Migrate an ASP.NET MVC Project to an ASP.NET Core Project
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (180).NET Core  (28).NET MAUI  (224)Angular  (113)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (41)Black Friday Deal  (1)Blazor  (234)BoldSign  (14)DocIO  (24)Essential JS 2  (110)Essential Studio  (199)File Formats  (72)Flutter  (135)JavaScript  (226)Microsoft  (121)PDF  (83)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (960)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)WPF  (162)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (10)Business intelligence  (55)Button  (4)C#  (163)Chart  (145)Chart of the week  (57)Cloud  (15)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (73)Development  (676)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (20)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (519)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (45)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (400)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (624)What's new  (337)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Easy Steps to Migrate an ASP.NET MVC Project to ASP.NET Core Project

Easy Steps to Migrate an ASP.NET MVC Project to an ASP.NET Core Project

ASP.NET MVC is a framework for developing web applications. It works on the model-view-controller pattern, and you can use it to develop only on Windows systems.

On the other hand, ASP.NET Core is a cross-platform web development framework that supports developing applications on Windows, Mac, Linux, iOS, and Android platforms. It has less maintenance, high performance, and more versatile features compared to the ASP.NET MVC.

In this blog post, we are going to learn how to upgrade an ASP.NET MVC web application by migrating it to ASP.NET Core by following these simple steps:

  1. Create an ASP.NET MVC sample project.
  2. Create an ASP.NET Core sample project.
  3. Migrate a register and login page to ASP.NET Core.
  4. Migrate views and controllers to ASP.NET Core.
  5. Migrate all layout files to ASP.NET Core.
  6. Test each action method in the Home controller.


Create an ASP.NET MVC sample project

First, we are going to create a simple ASP.NET MVC project by following these steps:

  1. Open Visual Studio and open the File menu. Then, navigate to New -> Project.
  2. Now, select ASP.NET Web Application (.NET Framework) and click Next.
  3. Name the project MVCWebApplication1, so that the namespace matches the ASP.NET Core project that will be created later in this blog post. Now, click Create.
  4. Next, select the MVC option, and then click Create.
  5. Finally, run the application.
    Create a Simple ASP.NET MVC Project

We have created a simple ASP.NET MVC project.

Create an ASP.NET Core sample project

Now, we are going to create a simple ASP.NET Core project.

  1. In Visual Studio, open the File menu and then navigate to New -> Project.
  2. Now, select the ASP.NET Core Web Application option and click Next.
  3. Then, the Configure your new project dialog will open. In it, enter the project name CoreWebApplication1. Using the same namespace makes it easier to copy code between the two projects. Now, click Create.
  4. In the Create a new ASP.NET Core Web Application dialog, confirm that the .NET Core and ASP.NET Core 3.1 options are selected. Then, select the Web Application (Model-View-Controller) project template and click Create.
  5. Finally, run the application.
    Creating a Simple ASP.NET Core Project

We have created a basic ASP.NET Core project.

Migrate register and login page to ASP.NET Core

In this section, we are going to migrate a register and login page to ASP.NET Core. Let’s get started.

  1. For authentication and identity features, install the following NuGet packages in ASP.NET Core:
  2. In the Startup.cs file, add the Startup.ConfigureService method to use the Entity Framework and Identity services as shown in the following code:
    public void ConfigureServices(IServiceCollection services)
        // Add EF services to the services container.
        services.AddDbContext<ApplicationDbContext>(options =>
        services.AddIdentity<ApplicationUser, IdentityRole>()
  3. Create a Models folder in the ASP.NET Core project and add the two classes ApplicationUser and ApplicationDBContext to their corresponding references from the ASP.NET MVC project. You can find these classes together in the Models/IdentityModels.cs file path in the ASP.NET MVC project.
    Refer to the following screenshot.
    Add the two classes ApplicationUser and ApplicationDBContext to their corresponding references from the ASP.NET MVC projectAlso, you can create separate classes for these classes as shown in the following code samples:

    using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
    namespace NewMvcProject.Models
      public class ApplicationUser : IdentityUser


    using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
    using Microsoft.Data.Entity;
    namespace NewMvcProject.Models
        public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
            public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
                : base(options)
            protected override void OnModelCreating(ModelBuilder builder)
                // Customize the ASP.NET Core Identity model and override the defaults if needed.
                // For example, you can rename the ASP.NET Core Identity table names and more.
                // Add your customizations after calling base.OnModelCreating(builder);
  4. Add the following namespaces in the Startup.cs file to compile:
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Identity;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.EntityFrameworkCore;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
  5. Add a new Razor view called _LoginPortal to the Views -> Shared folder and include the following code:
    @inject SignInManager<ApplicationUser> SignInManager
    @inject UserManager<ApplicationUser> UserManager
    @if (SignInManager.IsSignedIn(User))
        <form asp-area="" asp-controller="Account" asp-action="Logout" method="post" id="logoutForm" class="navbar-right">
            <ul class="nav navbar-nav navbar-right">
                    <a asp-area="" asp-controller="Manage" asp-action="Index" title="Manage">Hello @UserManager.GetUserName(User)!</a>
                    <button type="submit" class="btn btn-link navbar-btn navbar-link">Log out</button>
        <ul class="nav navbar-nav navbar-right">
            <li><a asp-area="" asp-controller="Account" asp-action="Register">Register</a></li>
            <li><a asp-area="" asp-controller="Account" asp-action="Login">Log in</a></li>

Migrate views and controllers to ASP.NET Core

Let’s migrate the views and controllers to the ASP.NET Core project with these simple steps:

  1. Navigate to Views -> Home directory. Then, add the About.cshtml, Contact.cshtml, and Index.cshtml view files from the ASP.NET MVC project.
  2. Then, in the Controllers -> HomeController.cs file, add all the methods from the ASP.NET MVC project.

Migrate the layout files to ASP.NET Core

Now, we are going to migrate all the layout files from the ASP.NET MVC project to the ASP.NET Core project.

  1. Add the _ViewStart.cshtml file from the ASP.NET MVC project in the Views folder.
  2. Then, in the Views -> Shared folder, add the _Layout.cshtml file from the ASP.NET MVC project.
  3. Make the following changes in the _Layout.cshtml file:
    • Replace the @Styles.Render(“~/Content/css”) code with the following:
      <link rel="stylesheet"
    • Remove the @Scripts.Render(“~/bundles/modernizr”) code.
    • Then, replace the @Scripts.Render(“~/bundles/jquery”) and @Scripts.Render(“~/bundles/bootstrap”) code with the following:
      <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
             integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

Test each action method in the Home controller

Now, run the ASP.NET Core application.

Run the ASP.NET Core ProjectThen, navigate to the Home, About, Contact, Login, and Register tabs to ensure the changes are correct. Refer to the following screenshots.


Check the About tabContact:

Check the Contact tab


Thanks for reading! In this blog post, we have learned how to migrate an ASP.NET MVC project to an ASP.NET Core project. You can create cross-platform apps for Windows, Mac, Linux, iOS, and Android platforms. So, try out the process yourself and leave your feedback in the comments section of this blog post!

With over 70 components, our Syncfusion ASP.NET Core toolkit powered by Essential JS 2 contains all you need for building line-of-business applications. It includes popular widgets such as a DataGrid, Charts, Gantt Chart, Diagram, Spreadsheet, Scheduler, and Pivot Table. Use them to enhance your productivity!

For existing customers, the new version is available for download from the License and Downloads page. If you are not yet a Syncfusion customer, you can try our 30-day free trial to check out the available features. Also, we encourage you to try our samples on GitHub.

Also, you can contact us through our support forumsupport portal, or feedback portal. We are always happy to assist you!

Recommended resources


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed