ASP.NET Core Web Application with .NET Framework, I want to switch the target to .NET Core - asp.net-core

I'm trying to change ASP.NET Core web application with .NET Framework as a target framework to use .NET Core 3.1.X
I try changing the target framework in the project file (.csproj), I encounter dependency issues, dependency conflict....
Is there any straightforward method to solve this issue?

Before you start your migration, you should know there’s several difference between .net framework and .net core, so please follow the official document to do some Pre-Migration steps.
Then you can follow this official document to migrate your application from framework to .net core 3.1.
Since your ideal .net core version is 3.1, still I suggest you can try to use .net 6. Also, you can use this upgrade tool to reach your goal. In fact, using this upgrade assistant is a batter choice than you doing it by yourself. Even if you are insisting using .net core 3.1, you can use this assistant to upgrade your version to 6 first then change it to 3.1.
Note:
Before you start your migration, please make a backup of your original project. That's because some packages in .net framework may be no longer available in .net core. So if there're some errors occur, you can go back to the original one.

Related

Helper library for ASP.NET Core 5 - NuGet packages not available?

I'm writing a helper library for ASP.NET Core 5 (with .NET 5) and I need some APIs from the package Microsoft.AspNetCore.Server.Kestrel.Core. However, the package is only available in version 2.2 - not version 5.
Is ASP.NET Core no longer distributed via NuGet? And if so, how does one get the APIs with ASP.NET Core 5.
Side note: I found that I could use Microsoft.NET.Sdk.Web as SDK for the project but I'm unsure whether this is a valid/good/correct approach when writing a library.
Is ASP.NET Core no longer distributed via NuGet? And if so, how does one get the APIs with ASP.NET Core 5.
That's correct. The core of ASP.NET Core (no pun intended...) ships with .NET Core >= 3.0 as a shared framework. You can add a single FrameworkReference to your nuget package to pull this in. See https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-5.0&tabs=visual-studio#migrate-libraries-via-multi-targeting for more information.
Some background can be found here https://github.com/dotnet/aspnetcore/issues/3756

It's very confusing.. I was creating .net core web application and can see .NetFramework with .NetCore support

I was creating .net core web application and can see .NetFramework with .NetCore support. But I didn't choose .Net Standard. I don't understand. Please see the image asp.net core web application
This is Microsoft naming at work here. 😁 There are two dotnet frameworks: the "full" framework, which you selected, and the dotnet core framework.
Before dotnet core and all it's optimized, multiplatform goodness, there was the dotnet framework (refered to as the legacy or full framework). This is the predecessor of dotnet core. This full framework runs only on Windows and the computer it runs on needs the dotnet framework runtime.
Do not worry, the "full" in full framework comes from the transition period between the old dotnet framework and dotnet core. When dotnet core was version 1.0, it did not have all the functionality of today. So some developers called it the full framework (which had everything you needed to run your application) and the newer dotnet core framework which had only the basics.
You can see if you are running the legacy framework if there is the <TargetFramework>netXXX</TargetFramework> present in your solution/project file. The lastest version of the full dotnet framework is 4.8 (net48).
After that it switched to dotnet core 1.0 - 3.1. I'm not entirely sure how that's referenced in the solution/project files.
As a last remark, Microsoft had a great naming idea: the next version of dotnet core is named dotnet 5. They want to get back to the original name with this next version. Do keep in mind that you cannot easily upgrade from dotnet 4.X to dotnet 5. The day to day code looks very much alike, but the underlying engine is completely rewritten.
As far as I know, before .net core 3.0, asp.net core is support on .net framework. This is the reason why you could create .net core 2.1 on the .net framework.
But after 3.0, asp.net core not support .net framework. You could only create it on .net core framework.
More details, you could refer to this article and this github issue.

.Net Core Project Referencing .Net Frameork Projects Problems?

I have a question about .net Core project.
I have a .Net Core Project referencing other projects.
The problem is that a few projects show the warning saying that "Package 'XXXXX' was restored using .NetFramework, Version=v4.6.1.... instead of targer framework .NetCoreApp".
What kind of problems could I have?
Also can I deploy this in Linux for instance and still working fine?
warning showed
Thanks guys
Look at this thread - For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6.1 packages?
What it basically means is the package you have loaded not suitable for .NET CORE, and was restored using a different version of .Net Framework.
Check if the package exists for .NET CORE (search thru NuGet Manager)
Regarding whether it will work on Linux or not - it depends on the package dependencies (e.g. if it is depending on WinForm for example, it probably won't work on Linux).
Even if it will work, I suggest finding a package suitable for .NET CORE.

Is NLog.Redis supported on .NET Core?

My previous project which is written on .NET Framework is using NLog.Redis to log information and visualize it on Kibana through Logstash. Is NLog.Redis supported on .NET Core to use in my new project?
Currently there there is no .NET Standard (and so .NET Core) version released.
There is an open pull request for it, see https://github.com/richclement/NLog.Redis/pull/7

Using Entity Framework 6 in ASP.NET Core

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://learn.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
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.
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.