Is EF Core missing anything in .NET Standard vs .NET Core library?

Ish Thomas

I'm building an ASP.NET Core Web API project. I will be heavily using EF Core with the connection with SQL Server. I want to organize the project around 3 main tiers: Core/Logic/Domain, Data/Infrastructure and Web/API.

Web/API will be definitely a .NET Core project, but I'm struggling with the decision whether Core and Data projects should be .NET Core library or .NET Standard library.

My question is, will I lose any features or anything while building my data persistence in .NET Standard library?

Chris Pratt

For a class library, the target framework simply specifies a compatibility layer. The ultimate functionality comes from the target framework of the project that references the class library.

For example, let's say that you create a .NET Standard library, and then you include that in a .NET Framework project. Everything you do happens on .NET Framework, and for all intents and purposes you could've targeted .NET Framework from your class library as well. The choice of .NET Standard simply says that you're going to use APIs from some .NET Standard-compliant target. That's all. As a result, the functionality of something like EF Core, ultimately depends on what you drop the library into, not what framework your library targets.

As to whether to choose .NET Standard or .NET Core as the target framework for your library, simply: use .NET Standard unless you have a good reason not to. If you target .NET Standard, you can drop it into any project that targets any framework that is compatible with the version of .NET Standard your library targets. If you choose .NET Core, you can only use the library in .NET Core projects.

Things get a little murkier when you start looking at .NET Core 3.0, though. You can technically target .NET Standard 2.1 and get all the goodness of .NET Core 3.0, but nothing but .NET Core 3.0 actually supports .NET Standard 2.1. You can target .NET Standard 2.0, but then you're stuck with .NET Core 2.2. In other words, if you want to use .NET Core 3.0, right now, there's no functional different between choosing .NET Standard 2.1 or .NET Core 3.0 as the target framework of your library. In either case, it will only work in .NET Core 3.0 projects.

Adding even more confusion, Microsoft is moving the next version of everything under the .NET 5 umbrella. What becomes of .NET Standard at that point hasn't been discussed, by I'd imagine it largely goes away. Once there's a .NET 5, any project can target .NET 5 and be used by any other project that targets .NET 5. That's still a ways off, though. The reason I bring it up, is that if you want to use .NET Core 3.0 today, there's not much point in targeting anything but .NET Core 3.0. Most of the stuff in .NET Standard 2.1 is not back-portable to things like .NET Framework and Unity, so those will never be on .NET Standard 2.1. The path forward for those frameworks is making them .NET Core compatible, to eventually end up with .NET Core 4.0, which Microsoft will call .NET 5.

Long and short, the best performance and features are with .NET Core 3.0, as long as you can go 100% .NET Core 3.0, then that's what you should target. If you need to use your library in something like an Xamarin or .NET Framework app, then stick with .NET Standard 2.0.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Is EF Core Add Migration Supported from .NET Standard Library?

分類Dev

.NET Standard、.NET Core、PCL

分類Dev

.NET Standardと.NET Core

分類Dev

.NET Standard、.NET Core、PCL

分類Dev

.NET Standard、.NET Core、PCL

分類Dev

Error during compilation with .NET 4.6.1 on a Nuget Class Library with EF core

分類Dev

.NET Core Class Library(.NET Standard)での依存性注入の使用

分類Dev

What is the difference between .NET Core and .NET Standard Class Library project types?

分類Dev

.NET Core development with VS 2012?

分類Dev

VS 2017 .NET Core BinaryFormatter

分類Dev

In ASP.NET CORE application EF Core library do not return new inserted record's ID from database?

分類Dev

IsGenericType & IsValueType missing from .Net Core?

分類Dev

.net core entity framework (EF Core) table naming convention

分類Dev

ASP.NET Core MVC と EF Core 1.1

分類Dev

Building .NET Standard and asp.net core together

分類Dev

Migrating Identity in .net core 2 class library

分類Dev

.NET Core SDK vs Runtime version for Docker

分類Dev

Class library that can be shared between .NET Framework and .NET Core

分類Dev

Referencing .NET 4.6.2 class library from .NET Core app

分類Dev

Which .Net framework should my .Net Core library target?

分類Dev

Using .NET Core library in .NET 4.5.2 console application

分類Dev

WPF Control Library Target .NET Core 3 or .NET Framework?

分類Dev

Is ViewData the new standard over ViewBag for ASP.Net 5 (core)?

分類Dev

.net core / standard string.ToLower() has no culture parameter

分類Dev

Database.Migrate() creating database but not tables, EF & .NET Core 2

分類Dev

difference between EF and Entity-SQL when working with .net core

分類Dev

Delete all related rows to user using EF .NET CORE

分類Dev

ODP.NET and EF6 configuration on ASP.NET Core targeting .NET 4.7.2

分類Dev

Build failing on .net Core app due to missing definition

Related 関連記事

  1. 1

    Is EF Core Add Migration Supported from .NET Standard Library?

  2. 2

    .NET Standard、.NET Core、PCL

  3. 3

    .NET Standardと.NET Core

  4. 4

    .NET Standard、.NET Core、PCL

  5. 5

    .NET Standard、.NET Core、PCL

  6. 6

    Error during compilation with .NET 4.6.1 on a Nuget Class Library with EF core

  7. 7

    .NET Core Class Library(.NET Standard)での依存性注入の使用

  8. 8

    What is the difference between .NET Core and .NET Standard Class Library project types?

  9. 9

    .NET Core development with VS 2012?

  10. 10

    VS 2017 .NET Core BinaryFormatter

  11. 11

    In ASP.NET CORE application EF Core library do not return new inserted record's ID from database?

  12. 12

    IsGenericType & IsValueType missing from .Net Core?

  13. 13

    .net core entity framework (EF Core) table naming convention

  14. 14

    ASP.NET Core MVC と EF Core 1.1

  15. 15

    Building .NET Standard and asp.net core together

  16. 16

    Migrating Identity in .net core 2 class library

  17. 17

    .NET Core SDK vs Runtime version for Docker

  18. 18

    Class library that can be shared between .NET Framework and .NET Core

  19. 19

    Referencing .NET 4.6.2 class library from .NET Core app

  20. 20

    Which .Net framework should my .Net Core library target?

  21. 21

    Using .NET Core library in .NET 4.5.2 console application

  22. 22

    WPF Control Library Target .NET Core 3 or .NET Framework?

  23. 23

    Is ViewData the new standard over ViewBag for ASP.Net 5 (core)?

  24. 24

    .net core / standard string.ToLower() has no culture parameter

  25. 25

    Database.Migrate() creating database but not tables, EF & .NET Core 2

  26. 26

    difference between EF and Entity-SQL when working with .net core

  27. 27

    Delete all related rows to user using EF .NET CORE

  28. 28

    ODP.NET and EF6 configuration on ASP.NET Core targeting .NET 4.7.2

  29. 29

    Build failing on .net Core app due to missing definition

ホットタグ

アーカイブ