Choosing between .NET Core and .NET Framework for server apps

There are two supported choices of runtime for building server-side applications with .NET: .NET Framework and .NET Core. Both share a lot of the same .NET platform components and you can share code across the two. However, there are fundamental differences between the two and your choice will depend on what you want to accomplish. This article provides guidance on when to use each.

You should use .NET Core for your server application when:

  • You have cross-platform needs.
  • You are targeting microservices.
  • You are using Docker containers.
  • You need high performance and scalable systems.
  • You need side by side of .NET versions by application.

You should use .NET Framework for your server application when:

    • Your application currently uses .NET Framework (recommendation is to extend instead of migrating)
    • You need to use third-party .NET libraries or NuGet packages not available for .NET Core.
    • You need to use .NET technologies that are not available for .NET Core.
    • You need to use a platform that doesn’t support .NET Core.

1

When to choose .NET Core

The following is a more detailed explanation of the previously-stated reasons for picking .NET Core.

Cross-platform needs

Clearly, if your goal is to have an application (web/service) that should be able to run across platforms (Windows, Linux and macOS), the best choice is to use .NET Core.

.NET Core also supports the previously-mentioned operating systems as your development workstation. Visual Studio provides an Integrated Development Environment (IDE) for Windows. You can also use Visual Studio Code on macOS, Linux and Windows which fully support .NET Core, including IntelliSense and debugging. You can also target .NET Core with most third-party editors like Sublime, Emacs, VI and can get editor IntelliSense using the open source Omnisharp project. You can also avoid any code editor and directly use the .NET Core command-line tools, available for all supported platforms.

Microservices architecture

.NET Core is the best candidate if you are embracing a microservices oriented system composed of multiple independent, dynamically scalable, stateful or stateless microservices. .NET Core is lightweight and its API surface can be minimized to the scope of the microservice. A microservices architecture also allows you to mix technologies across a service boundary, enabling a gradual embrace of .NET Core for new microservices that live in conjunction with other microservices or services developed with .NET Framework, Java, Ruby, or other monolithic technologies.2

The infrastructure platforms you could use are many. For large and complex microservice systems, you can use Azure Service Fabric. For stateless microservices you can also use other products like Azure App Service. Microservices alternatives based on Docker also fit any kind of microservices approach, as explained next. All these platforms support .NET Core and make them ideal for hosting your microservices.

Containers

Containers are commonly used in conjunction with a microservices architecture, although they can also be used to containerize web apps or services which follow any architectural pattern. You will be able to use the .NET Framework for Windows containers, but the modularity and lightweight nature of .NET Core makes it perfect for containers. When creating and deploying a container, the size of its image is far smaller with .NET Core than with .NET Framework. Because it is cross-platform, you can deploy server apps to Linux Docker containers, for example.

You can then host your Docker containers in your own Linux or Windows infrastructure, or use a cloud service such as Azure Container Service which can manage, orchestrate and scale your container-based application in the cloud.

A need for high performance and scalable systems

When your system needs the best possible performance and scalability, .NET Core and ASP.NET Core are your best options. ASP.NET Core outperforms ASP.NET by a factor of 10, and it leads other popular industry technologies for microservices such as Java servlets, Go and node.js.

This is especially relevant for microservices architectures, where you could have hundreds of microservices running. With ASP.NET Core you’d be able to run your system with a much lower number of servers/VMs, ultimately saving costs in infrastructure and hosting.

A need for side by side of .NET versions per application level

If you want to be able to install applications with dependencies on different versions of frameworks in .NET, you need to use .NET Core, which provides 100% side-by-side. Easy side-by-side installation of different versions of .NET Core on the same machine allows you to have multiple services on the same server, each of them on its own version of .NET Core, eliminating risks and saving money in application upgrades and IT operations.1

When to choose .NET Framework

While .NET Core offers significant benefits for new applications and application patterns, the .NET Framework will continue to be the natural choice for many existing scenarios and as such, it won’t be replaced by .NET Core for all server applications.

Current .NET Framework applications

In most cases, you won’t need to migrate your existing applications to .NET Core. Instead, a recommended approach is to use .NET Core as you extend an existing application, such as writing a new web service in ASP.NET Core.1

A need to use third-party .NET libraries or NuGet packages not available for .NET Core

Libraries are quickly embracing .NET Standard, which enables sharing code across all .NET flavors including .NET Core. With .NET Standard 2.0 this will be even easier, as the .NET Core API surface will become significantly bigger and .NET Core applications can directly use existing .NET Framework libraries. This transition won’t be immediate, though, so we recommend checking the specific libraries required by your application before making a decision one way or another.

A need to use .NET technologies not available for .NET Core

Some .NET Framework technologies are not available in .NET Core. Some of them will be available in later .NET Core releases, but others don’t apply to the new application patterns targeted by .NET Core and may never be available. The following list shows the most common technologies not found in .NET Core 1.0:1

    • ASP.NET Web Forms applications: ASP.NET Web Forms is only available on the .NET Framework, so you cannot use ASP.NET Core / .NET Core for this scenario. Currently there are no plans to bring ASP.NET Web Forms to .NET Core.
    • ASP.NET Web Pages applications: ASP.NET Web Pages are not included in ASP.NET Core 1.0, although it is planned to be included in a future release as explained in the .NET Core roadmap.
    • ASP.NET SignalR server/client implementation. At .NET Core 1.0 release timeframe (June 2016), ASP.NET SignalR is not available for ASP.NET Core (neither client or server), although it is planned to be included in a future release as explained in the .NET Core roadmap. Preview state is available at the Server-side and Client Library GitHub repositories.
    • WCF services implementation. Even when there’s a WCF-Client library to consume WCF services from .NET Core, as of June 2016, WCF server implementation is only available on the .NET Framework. This scenario is not part of the current plan for .NET Core but it’s being considered for the future.
    • Workflow related services: Windows Workflow Foundation (WF), Workflow Services (WCF + WF in a single service) and WCF Data Services (formerly known as "ADO.NET Data Services") are only available on the .NET Framework and there are no plans to bring them to .NET Core.
    • Windows Presentation Foundation (WPF) and Windows Forms: WPF and Windows Forms applications are only available on the .NET Framework. There are no plans to port them to .NET Core.
    • Language support: Visual Basic and F# don’t currently have tooling support .NET Core, but both will be supported in Visual Studio 2017 and later versions of Visual Studio.

4

In addition to the official roadmap, there are other frameworks to be ported to .NET Core - For a full list, take a look at CoreFX issues marked as port-to-core. Please note that this list doesn’t represent a commitment from Microsoft to bring those components to .NET Core — they are simply capturing the desire from the community to do so. That being said, if you care about any of the components listed above, consider participating in the discussions on GitHub so that your voice can be heard. And if you think something is missing, please file a new issue in the CoreFX repository.

A need to use a platform that doesn’t support .NET Core

Some Microsoft or third-party platforms don’t support .NET Core. For example, some Azure services such as Service Fabric Stateful Reliable Services and Service Fabric Reliable Actors require .NET Framework. Some other services provide an SDK not yet available for consumption on .NET Core. This is a transitional circumstance, as all of Azure services use .NET Core. In the meantime, you can always use the equivalent REST API instead of the client SDK.

时间: 2024-10-07 14:35:30

Choosing between .NET Core and .NET Framework for server apps的相关文章

[UWP小白日记-11]在UWP中使用Entity Framework Core(Entity Framework 7)操作SQLite数据库(一)

前言 本文中,您将创建一个通用应用程序(UWP),使用Entity Framework Core(Entity Framework 7)框架在SQLite数据库上执行基本的数据访问. 准备: Entity Framework Core(Entity Framework 7)下文将简称:EF 1.在UWP中使用EF需要更新Microsoft.NETCore.UniversalWindowsPlatform到大于“5.2.2”的版本. 2.直接在“程序包管理器控制台”输入命令来更新:Update-P

Mono ASP.NET core 添加 Entity Framework

Mono ASP.NET core 添加 Entity Framework 的时候, 仅仅用 Nuget 添加  System.Data.Entity 是没用的. 还需要添加一个叫做 EntityFramework 的包才能使用.

ubuntu .net core The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found

想在ubuntu下试试.net core mvc,按照官方教程走完,然后把在window 下做好的项目想在ubuntu下试试,然后输入了 git clone https://github.com/kastier/a_test_dotnet_core.git ,然后运行,结果发现没法运行,报出错误: The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found 我就想重新安装,但是又不知道对应的版本号,

.NET Core 和 .NET .Framework 速度比较

废话不多说! 一下是 .NET core 和 .NET framework 速度对比. 两者使用最慢的冒泡排序算法:  排序10万条数据 次数 .NET CORE(耗时) .NET framework(耗时)  第一次    第二次     第三次     平均下来.net core 需要39秒, 而.net fw 平均49秒.  在同等条件下 .net core  性能领先. 这只是个简单得测试.我相信.net core 不会让.net 程序员失望的. 一下代码,各位可以测试下. static

登录注册的小项目对比.Net Core与 .Net Framework的一些区别

一.需求: 1.功能只有登录.注册. 二.架构: 1.分别为 UserSys.IServices:主要有实体和对实体的配置,还有对实体的操作接口 UserSys.Services :主要是对自IService层中的接口实现 UserSys.DTO :主要是我们Web层中需要什么实体就给传递什么实体 UserSys.Common:一些通用的组件封装到该类库中 UserSys.Web:Asp.Net MVC 2.Web层采用Asp.Net MVC 3.数据库访问通过EF 三.具体实现    1.写U

ASP.NET Core 开发-Entity Framework (EF) Core 1.0 Database First

ASP.NET Core 开发-Entity Framework Core 1.0 Database First,ASP.NET Core 1.0 EF Core操作数据库. Entity Framework Core 1.0 也已经发布了,可以适用于 .NET Core 1.0 及ASP.NET Core 1.0 . EF Core RC2 时,使用的Code First: http://www.cnblogs.com/linezero/p/EntityFrameworkCore.html E

Building a Web App with ASP.NET Core, MVC, Entity Framework Core, Bootstrap, and Angular

Since I have spent many years on Windows Application development in my first three years of software career.  I was interested in the C#, had tried to understand the basic knowledge about C#. The programs, the patterns, the object-oriented methodolog

ASP.NET Core 配置 Entity Framework Core - ASP.NET Core 基础教程 - 简单教程,简单编程

原文:ASP.NET Core 配置 Entity Framework Core - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 配置 Entity Framework Core 上一章节学习完了视图,其实我们应该立即着手讲解模型的,但 ASP.NET Core MVC 中的模型和 Entity Framework 有相当大的关系,所以,在此之前,我们先来讲讲 Entity Framework Core 和如何配置它 本章中,我们将设置和配置我们的应用程

.NET Core、.NET Standard 、ASP.NET Core 和 .NET Framework 有什么不同?

经查阅.Net Core相关资料: https://www.infoq.cn/article/2017%2F10%2Fdotnet-core-standard-difference https://blog.csdn.net/yiyelanxin/article/details/84439216 对.NET Core..NET Standard .ASP.NET Core 和 .NET Framework有了初步的了解: .NET Core .NET Core是免费.跨平台的,是托管框架的开源实