Skip to content

abdurrahman/dotnet-core-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dotnet-core-postgresql

A sample MVC project about how to use PostgreSQL with ASP.NET Core.

You can take a look Medium post for detailed instructions [TR]

This project uses;

  • .NET 5.0 target framework.
  • Npgsql.EntityFrameworkCore.PostgreSQL 5.0.2 NuGet package.

Project Setup

Clone repo

$ git clone https://github.com/abdurrahman/dotnet-core-postgresql.git

Update appsettings.json

Configure connection string in project's appsettings.json, replacing the username, password, and dbname appropriately (Consider to change Server name if it necessary):

"ConnectionStrings": {
    "DefaultConnection": "User ID=username;Password=password;Server=localhost;Port=5432;Database=dbname;Integrated Security=true;Pooling=true;"
},

Running the migration

Execute the following comment inside the project directory, where the .csproj file is located:

$ dotnet ef database update

After running the migration, the database is created and web application is ready to be run.