Using Entity Framework 6 in ASP.NET Core

2019-01-26 11:22发布

Let's say I have:

  • ASP.NET Core stand alone Web API project for .NET Core framework
  • Class Library with EF6 data model for full .NET framework

The ASP.NET Core project refers to the class library

This architecture proposed here:

https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6

The question is: will my standalone application be able to execute on the specified target platform (Win, Linux, Mac runtime) after Release (or Publish), if it's dependency targets to full .NET Framework?

Thanks very much

2条回答
劫难
2楼-- · 2019-01-26 11:29

Disclaimer: I'm the owner of the project Entity Framework Classic

That's not possible directly Entity Framework as @Adailson answered

However, it's possible via EF Classic: http://entityframework-classic.net/

That's an EF6 fork that also supports .NET Core. We plan to integrate a ton of features & bug fix.

A community (FREE) and enterprise version (PAID) is available.

What's EF Classic

Entity Framework Classic is a supported version from the latest EF6 code base. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.

查看更多
Deceive 欺骗
3楼-- · 2019-01-26 11:33

It will be not possible. The same link you provided confirm that:

To use Entity Framework 6, your project has to compile against .NET Framework, as Entity Framework 6 does not support .NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.

You can use ASP.NET Core upon .NET Framework (Not .NET CORE) and EF6 (But not cross-platform). But not ASP.NET Core upon .NET Core and use EF6. You will need to use EF Core for that project.

查看更多
登录 后发表回答