Skip to main content

PostgreSQL/Npgsql provider for Entity Framework Core.

Total Downloads
572.6M
572,643,810
Published
Nov 20, 2026
3d ago

Get Started

dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 11.0.0
ProductVersions
.NET
net11.0

README

Npgsql Entity Framework Core provider for PostgreSQL

Npgsql.EntityFrameworkCore.PostgreSQL is the open source EF Core provider for PostgreSQL. It allows you to interact with PostgreSQL via the most widely-used .NET O/RM from Microsoft, and use familiar LINQ syntax to express queries. It's built on top of Npgsql.

The provider looks and feels just like any other Entity Framework Core provider. Here's a quick sample to get you started:

await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

// Insert a Blog
ctx.Blogs.Add(new() { Name = "FooBlog" });
await ctx.SaveChangesAsync();

// Query all blogs who's name starts with F
var fBlogs = await ctx.Blogs.Where(b => b.Name.StartsWith("F")).ToListAsync();

public class BlogContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder.UseNpgsql(@"Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase");
}

public class Blog
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Aside from providing general EF Core support for PostgreSQL, the provider also exposes some PostgreSQL-specific capabilities, allowing you to query JSON, array or range columns, as well as many other advanced features. For more information, see the the Npgsql site. For information about EF Core in general, see the EF Core website.

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

Teams using PostgreSQL features such as JSONB, arrays or advanced indexing patterns.

Entity Framework Guide
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Editorial Note: EF Core provider for PostgreSQL with strong support for PostgreSQL-specific capabilities. Trade-off: Provider-specific behavior and SQL translation should be validated when porting from SQL Server-centric models.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.