.NET on AWS — Data Persistence using RDS

5 min readApr 16, 2022
Photo by Carlos Muza on Unsplash


In previous Post on this topic, we started by publishing a .NET Core API to AWS Lambda function.

Today, we will extend the API and add more functionality to it (database operations) and then redeploy it to AWS Lambda and see how it goes.

Database Setup

We’ll be using Postgres database (AWS RDS) for data persistence. I’ve written few posts on this topic, which you can check and these will provide you all the background information you need to work with PostgreSQL database in .NET Core:

Also, I will be using Dapper as an ORM, but feel free to use EntityFramework if you want to.

So, I’ve setup a PostgreSQL (RDS) database and created products and users tables as shown below:

As you can see that I’ve also populated some initial data in the database.

.NET Core API with RDS Database

On the .NET Core Application side, I have added two new projects (.NET Standard class libraries) and installed the Dapper NuGet package to dempApp.Data project as shown below:

demoApp.Data project will also house the Repositories, which will be injected and used in the controller.

We could have added all these items in the API project, but having separate projects (libraries) will help us with separation of concern and easy to manage complexity when application grows.

Dependency Injection


Software Solutions Team Lead | Cloud Architect | Solutions Architect