Deploying ASP.NET 5 RC1 on Linux with Kestrel and Entity Framework 7 on Alibaba Cloud

This article details the experience of upgrading a sample site to ASP.NET 5 RC1 on Linux, configuring Kestrel as the web server, adding SQL Server access via Entity Framework 7, handling Alibaba Cloud RDS settings, and discussing performance issues observed with Alibaba Cloud load balancing.

DevOps
DevOps
DevOps
Deploying ASP.NET 5 RC1 on Linux with Kestrel and Entity Framework 7 on Alibaba Cloud

The post introduces the recent release of ASP.NET 5 RC1, highlighting its cross‑platform capabilities and its significance for .NET developers in China.

Following the release, the author upgraded the demo site http://about.cnblogs.com to ASP.NET 5 RC1 and added database access using Entity Framework 7 RC1 to a SQL Server instance hosted on Alibaba Cloud RDS. A specific collation (SQL_Latin1_General_CP1_CS_AS) is required to work around a SqlClient bug.

Database migration commands used:

dnx ef migrations add FirstMigration
dnx ef database update

The connection string is read from config.json. The backend web server runs on Kestrel, while the front‑end traffic is routed through Alibaba Cloud Load Balancer. Direct access to Kestrel is fast, but requests via the load balancer hang for up to a minute, suggesting a TCP communication issue.

Project file structure:

.
├── config.json
├── Controllers
│   ├── AboutController.cs
│   └── HomeController.cs
├── Data
│   ├── EfDbContext.cs
│   ├── ITabNavRepository.cs
│   └── TabNavRepository.cs
├── Extensions
│   └── HtmlHelperExtensions.cs
├── Models
│   └── TabNav.cs
├── project.json
├── project.lock.json
├── Startup.cs
├── Views
│   ├── About
│   │   ├── Ad.cshtml
│   │   ├── Contact.cshtml
│   │   ├── Intro.cshtml
│   │   └── Job.cshtml
│   ├── Shared
│   │   └── _Layout.cshtml
│   └── _ViewStart.cshtml
└── wwwroot

Key excerpt from project.json (relevant sections only):

{
  "webroot": "wwwroot",
  "exclude": ["wwwroot"],
  "commands": {
    "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:8001",
    "ef": "EntityFramework.Commands"
  },
  "dependencies": {
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-*",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "System.Runtime.Serialization.Primitives": "4.0.10-*",
    "System.Net.Security": "4.0.0-*"
  },
  "frameworks": {
    "dnxcore50": {}
  }
}

Relevant portion of Startup.cs showing configuration and service registration:

using System;
using System.Linq;
using Microsoft.AspNet.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Data.Entity;
using CNBlogs.AboutUs.Data;
using Microsoft.Dnx.Runtime;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.Extensions.Configuration;
using System.Data.SqlClient;
using Microsoft.Extensions.Logging;

namespace CNBlogs.AboutUs.Web
{
    public class Startup
    {
        public Startup(IApplicationEnvironment appEnv)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json", false);
            Configuration = builder.Build();
        }
        public IConfiguration Configuration { get; set; }
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();
            app.UseDeveloperExceptionPage();
            app.UseMvcWithDefaultRoute();
            app.UseStaticFiles();
            app.UseRuntimeInfoPage();
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<EfDbContext>(options =>
                {
                    options.UseSqlServer(Configuration["data:ConnectionString"]);
                });
            services.AddTransient<ITabNavRepository, TabNavRepository>();
        }
    }
}

The author concludes that SQL Server can now be accessed cross‑platform, and if Kestrel’s stability improves, more .NET sites will be migrated to Linux using ASP.NET 5.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Alibaba CloudSQL ServerASP.NETEntity FrameworkKestrel
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.