PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. postgresql.org/about
The good thing is, we can easily use this as our database for our ASP.NET Core Web App.
So enough intro, let’s get started.
Make sure you already downloaded and installed PostgreSQL in your machine. If you haven’t installed yet, you can visit this link http://www.postgresqltutorial.com/install-postgresql/.
In this sample, I’m using ASP.NET Core Web API project but the procedure can be implemented in ASP.NET Core MVC.
1.1 Open the terminal and execute the command or open Nuget Package Manager. Look for this package.
Npgsql.EntityFrameworkCore.PostgreSQL

Install-Package Npgsql.EntityFrameworkCore.PostgreSQL
You can find different versions here that fits on your .net core version.
Locate your the method that implements DbContextOptionsBuilder optionsBuilder
and update your connection string similar to this. Normally you can find them in your Startup.cs or in your DbContext file.
optionsBuilder.UseNpgsql(@"Server=127.0.0.1;Port=5432;Database=myDataBase;User Id=myUsername;Password=myPassword;");
The example above is only a standard connection string, if you want the other options, you can find them here.
One you finish the steps above, you can now do the migrations and database update using your command line.
dotnet ef migrations add InitialCreateToPostgreSQL
dotnet ef database update
That’s it. It’s very simple to setup!
If you have some questions or comments, please drop it below 👇 :)
