Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't install Npgsql.EntityFrameworkCore.PostgreSQL in my .NET 7 app

I was following the next video to add support for EF with PostgreSQL:

https://www.youtube.com/watch?v=pRxG9ORD7Hk

Yet, I got the next results while trying this dotnet add package cmd:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
  Determining projects to restore...
  Writing /tmp/tmpbRFUdc.tmp
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/lib/dotnet/sdk/7.0.112/trustedroots/codesignctl.pem'.
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/lib/dotnet/sdk/7.0.112/trustedroots/timestampctl.pem'.
info : Adding PackageReference for package 'Npgsql.EntityFrameworkCore.PostgreSQL' into project '/application/gitCola/vivo_prof_editor/vivo_prof_editor.csproj'.
info :   CACHE https://api.nuget.org/v3/registration5-gz-semver2/npgsql.entityframeworkcore.postgresql/index.json
info : Restoring packages for /application/gitCola/vivo_prof_editor/vivo_prof_editor.csproj...
error: NU1202: Package Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0 is not compatible with net7.0 (.NETCoreApp,Version=v7.0). Package Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0 supports: net8.0 (.NETCoreApp,Version=v8.0)
error: Package 'Npgsql.EntityFrameworkCore.PostgreSQL' is incompatible with 'all' frameworks in project '/application/gitCola/vivo_prof_editor/vivo_prof_editor.csproj'.
root@32e183e2b6e8:/application/gitCola/vivo_prof_editor# 

I am using .NET 7 so I suppose this "add package" cmd tries to install for .NET 8 by default. How can I restrict it to .NET 7?

>Solution :

You can specify the version of the nuget package you are installing in the command like below:

dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 7.0.11

7.0.11: This is the latest version of the package that supports .Net7

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading