ASP.NET Core — Entity Framework Core with PostgreSQL Database

A guide to using ASP.NET Core MVC Identity with PostgreSQL

ASP.NET Core — Entity Framework Core with PostgreSQL Database

PostgreSQL

Prerequisites

IDE’s

Implementing the Project

Creating a new project

Create a new project
Create a new project

Configure your new project

Configure your new project
Configure your new project

Choosing the template

Install Entity Framework Core & PostgreSQL

Example of installing a package

Configuration

Startup.cs
Startup.cs — After adding PostgreSQL

Create a User Model

User.cs

Create the APIContext

Adding a Class
APIContext.cs

Creating the Database

postgres=# CREATE DATABASE "ASPPostgreSQL.Db";

Adding the ConnectionStrings

User ID=postgres;Password=psql;Server=localhost;Port=5432;Database=ASPPostgreSQL.Db;Integrated Security=true;Pooling=true;

Database Migration

PM> Add-Migration InitialMigration
PM> Update-Database