Sindre
Sindre

Reputation: 45

.NET Core Web application using .NET Framework business layer with .NET Standard between

In my solution I have a business layer containing some projects that target .NET Framework 4.7 (including EntityFramework data access layer and a lot of logic). Now I want to make a web application with .NET Core 2.2. I realise that .NET Core is not compatible with .NET Framework, but .NET Standard is compatible with both. Converting the business layer from .NET Framework to .NET Standard or .NET Core is not an option, as it is simply too much work.

My Question:

Is it possible to add a .NET Standard project in my business layer as a middleman, taking all the request from the .NET Core Web app and calling code (including accessing EF data) in my .NET Framework projects?

Upvotes: 0

Views: 566

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239460

No. That is not possible. Regardless of how many layers you add in between, there's still a dependency on EF6, which .NET Core currently does not support. You have two choices:

  1. You can make your ASP.NET Core project target .NET Framework as well. Just because it has "Core" in the name, doesn't mean it has to target .NET Core. You of course won't be able to run cross-platform at that point, but if you're already running pieces of the application targeting .NET Framework, that's likely not an issue.

  2. You can ignore the current code entirely and create separate DAL for the ASP.NET Core app that uses EF Core and treats the database as existing, allowing you scaffold in entities to represent the database. This of course adds some code duplication, but since you can just rescaffold any time the database changes, it's relatively minor.

For what it's worth, .NET Core 3.0 (currently in preview) will natively support EF6, so once that's released, you can target .NET Core with no issue.

Upvotes: 2

Related Questions