Update Infrastructure project

Open Northwind.sln solution.

Manage Nuget Packages

Remove Microsoft.EntityFrameworkCore.SqlServer Nuget package from the Infrastructure project.

SQL Nuget

Add Npgsql.EntityFrameworkCore.PostgreSQL Nuget package to the Infrastructure project (version 3.1.2)

Please use version 3.1.2 and not the latest version.

Postgre Nuget

Change database provider

Update Infrastructure/DependencyInjection.cs file:

services.AddDbContext<ApplicationDbContext>(options =>

Update DesignTimeDbContextFactoryBase.cs file:

private const string ConnectionStringName = "NorthwindPostgreDatabase";

Once you build solution, there will be errors in Persistence project saying Cannot resolve symbol IsClustered in the lines like the following:

builder.HasKey(e => new { e.EmployeeId, e.TerritoryId }).IsClustered(false);

In order to fix it, just remove .IsClustered(false) from all places.

Update migrations

Remove existing migrations (delete Infrastructure/Migrations folder).

In order to run following commands, you should be inside Src/Infrastructure folder.

Recreate migrations:

dotnet ef migrations add InitialPostgre

Apply migrations to the database:

dotnet ef database update

You should see an output that migration was applied successfully:

Build started...
Build succeeded.
DesignTimeDbContextFactoryBase.Create(string): Connection string: 'Server=northwind-postgresql.cluster-cn0kwmvargy2.eu-west-1.rds.amazonaws.com;Database=NorthwindTraders;Username=adminuser;Password=Admin12345?'.
Applying migration '20210329132525_InitialPostgre'.