How to make database connection in ASP.NET core with postgres SQL ?
CodePudding user response:
use the Npgsql EF Core provider, add a dependency on Npgsql.EntityFrameworkCore.PostgreSQL. You can follow the instructions in the general EF Core Getting Started docs.

ConfigureServices in startup.cs:
Once you successfully added the Nuget package then you have to update following code on your project ConfigureServices under startup.cs
services.AddDbContext<YourDatabaseContextClassName>(options =>
options.UseNpgsql(Configuration.GetConnectionString("YourDatabaseContextStringNameFromAppsettings")));
Note:If you need any example forentityframeworkandPostgre SQLimplementation you can have look here
For further assistance you can have look on official document here. Hope it would guide you accordingly.
