Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Entity Framework 6 (not core) in .net core?

Entity Framework Core does not support spatial data, which I need to use in my app.

Can I use Entity Framework 6 in .net core? If so, how can I register DatabaseContext in Startup.cs?

like image 485
kostik Avatar asked Jan 08 '18 18:01

kostik


People also ask

Should I use EF core or EF6?

EF Core vs EF 6EF 6 is a stable and mature ORM while EF Core is relatively new. Microsoft rebuilt EF Core from the ground up and removed many of the internal dependencies and providers that EF 6 had (like SQLClient). In the long run, that will make EF Core much more extensible and lighter weight.

Can I use EF in .NET core?

There's currently no support for using the EF designer directly on . NET Core or . NET Standard projects.

Is .NET 6 the same as .NET Core 6?

NET 6 is an open-source and cross-platform framework, meaning that it automatically replaces . NET Core and . NET Framework with a single, more powerful, unified platform.

Does EF core 6 require .NET 6?

Supported platforms. EF Core 6.0 requires . NET 6. EF Core 6.0 does not target any .


1 Answers

Update

You can now use EF 6.3 with .NET Core 3.0:

https://devblogs.microsoft.com/dotnet/announcing-ef-core-3-0-and-ef-6-3-general-availability/#what-s-new-in-ef-6-3

Below is an excerpt. However, EF Core has come a long way these days and it's worth giving it another go before going back to something that's reaching end-of-life soon. Specifically for your issue, EF Core supports mapping to spatial data types using the NetTopologySuite spatial library since version 2.2.

What’s new in EF 6.3

  • Support for .NET Core 3.0

  • The EntityFramework package now targets .NET Standard 2.1 in addition to .NET Framework 4.x.

  • This means that EF 6.3 is cross-platform and supported on other operating systems besides Windows, like Linux and macOS.

  • The migrations commands have been rewritten to execute out of process and work with SDK-style projects.

  • Support for SQL Server HierarchyId.

  • Improved compatibility with Roslyn and NuGet PackageReference.

  • Added ef6.exe utility for enabling, adding, scripting, and applying migrations from assemblies. This replaces migrate.exe. There are certain limitations when using EF 6.3 in .NET Core. For example:

  • Data providers need to be also ported to .NET Core. We only ported the SQL Server provider, which is included in the EF 6.3 package.

  • Spatial support won’t be enabled with SQL Server because the spatial types aren’t enabled to work with .NET Core.

  • Note that this limitation applies to EF 6.3 but not to EF Core 3.0. The latter continues to support spatial using the NetTopologySuite library.

  • There’s currently no support for using the EF designer directly on .NET Core or .NET Standard projects.

Original Answer

It isn’t ready yet, but starting with .NET Core 3.0, you will be able to.

https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-3-and-support-for-windows-desktop-applications/

Similarly, EF6 will be updated to work on .NET Core 3.0, to provide a simple path forward for existing applications using EF6.

https://youtu.be/GN54OV5cCBM?t=1146

But there's also EF6, which we've already announced is going to be ported to work on .NET Core...

like image 87
Saeb Amini Avatar answered Sep 21 '22 16:09

Saeb Amini