Project ‘ClassLibrary1.csproj’ targets ‘netcoreapp2.1’. It cannot be referenced by a project that targets ‘.NETFramework,Version=v4.7.2’

You are not able to reference: .NET Core libraries from .NET Framework .NET Framework libraries from .NET Core If you want to share code between those two libraries you have to use .NET Standard libraries. .NET Standard is a kind of interface, a versioned list of APIs that you can call, .NET Framework and .NET … Read more

LocalDB is not supported on this Platform

LocalDb is a packaging mechanism for SQL Server Express Edition, and is only available for Windows. On Ubuntu you can install regular SQL Server Express Edition. https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-overview Here are the install scripts for Ubuntu, Red Hat, and SUSE. Or use the Docker Images: https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker

Configuration for console apps .net Core 2.0

It seems there is no change, as Jehof says. ConfigurationBuilder is in its own package, as Jeroen Mostert says. But make sure you also have the Microsoft.Extensions.Configuration.Json package, where the .AddJsonFile() extension lives. In summary, you need the following two NuGet packages: Microsoft.Extensions.Configuration (2.0.0) Microsoft.Extensions.Configuration.Json (2.0.0)

The DbContext of type cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions

When using DbContext Pooling, your own state (e.g. private fields) in your derived DbContext class will be preserved. Which means the lifetime of your services is now singleton. That’s why you shouldn’t have other injected services here. But it’s possible to query the required services this way: First we should use the UseInternalServiceProvider method on … Read more

C# Add Accept header to HttpClient

There is no difference. DefaultRequestHeaders.Accept is a collection of string type, where you can add your header to accept using the new instance of MediaTypeWithQualityHeaderValue. client.DefaultRequestHeaders is a dictionary that accepts key for and value for the request header and matches the results according to them. DefaultRequestHeaders has overloads. The only thing that differs between … Read more

Upgrading to .NET Core 2.0: PackageTargetFallback and AssetTargetFallback cannot be used together

In .NET Core 1.0 and 1.1, it was needed to set PackageTargetFallback when referencing packages that are known to work on .NET Core but don’t officially support it – e.g. PCL libraries or libraries built for the legacy dotnet framework moniker. Due to this, the project (.csproj, .fsproj, …) will contain a line similar to: … Read more

Error message “CS5001 Program does not contain a static ‘Main’ method suitable for an entry point”

It means that you don’t have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project file: <LangVersion>7.1</LangVersion> or more generally: <LangVersion>latest</LangVersion> You also need to rename MainAsync to Main. So for example: Program.cs: using … Read more

Error NU1605 Detected package downgrade

I had a similar issue with a .netcoreapp2.2 console application. The project was building successfully. However, publishing was failing with several NU1605 errors. The problem was originated from log4net version 2.0.8. It was referenced in a .netstandard2.0 project with the following dependencies: They were causing package downgrades in the projects referencing log4net. And during publish … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)