why can't I download Microsoft.EntityFrameworkCore.SqlServer to my DAL (WEB API) in c#?

49 Views Asked by At

I need some help. I want to write an ASP.NET Web API in C# (I created a project on the .NET framework), but first I need to connect it to my database in SQL Server.

In order to connect to the database, I created another project in my solution, a class library (.NET framework).

I need to download Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools from the NuGet Package Manager.

When I try to download Microsoft.EntityFrameworkCore.SqlServer version 8.0.0 (which is not even the latest version) I get this error:

Error: Could not install package 'Microsoft.EntityFrameworkCore.SqlServer 8.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

The same happens when I try to install the tools.

Why does it happen? I have Visual Studio 2022, never changed the version of my .NET Framework. And I remember a few month ago, succeeding doing such a task...

Thanks for helping!

1

There are 1 best solutions below

0
Lynn Crumbling On

You are targetting .NET Framework. Entity Framework Core only supports the .NET Core lineage of .NET (such as .NET Core 2.x, 3.x, and .NET 5, 6, 7, and 8.) In this case, you should create a new class library which targets .NET 8.