Npgsql Entity Framework Core provider for PostgreSQL
Entity Framework Core provider for PostgreSQL
At a glance
- What is it?
- Npgsql.EntityFrameworkCore.PostgreSQL connects EF Core applications to PostgreSQL through Npgsql, with LINQ queries and support for PostgreSQL-specific data types. It suits .NET teams using EF Core, with package compatibility and schema safety requiring review.
- Who is it for?
- Adopt Npgsql.EntityFrameworkCore.PostgreSQL when the application uses .NET, EF Core, PostgreSQL, and needs PostgreSQL-specific data types or related plugins. Do not choose it for another database or an EF Core version outside the selected package's supported range.
- Can I use it commercially?
- Yes. PostgreSQL is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 10 days ago.
- What is it written in?
- Mainly C#, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 7, 2026, and from our analysis. They are not legal advice.
Star history
- npgsql/efcore.pg1,840 ★ · -1
| Repository | 2026-10-16 | 2026-11-07 |
|---|---|---|
| npgsql/efcore.pg | 1.8k | 1.8k |
-1 Stars in the last 22 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Where Npgsql.EntityFrameworkCore.PostgreSQL fits in EF Core
Npgsql.EntityFrameworkCore.PostgreSQL is the database provider that lets an Entity Framework Core application use PostgreSQL as its backing store. Its intended users are .NET developers who already depend on Entity Framework Core and LINQ. The provider lets those applications express database operations through EF Core abstractions while retaining access to PostgreSQL-specific column types and query capabilities.
The package is built on top of Npgsql, the ADO.NET provider for PostgreSQL. The visible stack therefore has three layers. Application code uses EF Core and LINQ. Npgsql.EntityFrameworkCore.PostgreSQL handles EF Core integration with PostgreSQL. Npgsql manages the lower-level database connection. When diagnosing a failure, these boundaries help distinguish an EF Core mapping or query problem from an issue in the provider or the underlying connection.
This project is not a standalone ORM, PostgreSQL server, or migration authoring system. It is a provider within an existing .NET data-access stack. It becomes relevant when a team wants an EF Core application to use PostgreSQL without replacing its DbContext, LINQ, change tracking, or related EF Core conventions throughout the application.
The README directs general EF Core questions to Microsoft's EF Core website. That separation defines the provider's scope. This repository describes PostgreSQL integration and extensions such as JSON, array, and range queries. Broader concerns such as DbContext lifetime, change tracking, and migrations remain governed by EF Core documentation unless this repository gives provider-specific instructions.
How LINQ reaches PostgreSQL through Npgsql
The README example shows the normal EF Core path from configuration to query. A BlogContext derives from DbContext and exposes a DbSet for Blog entities. Its OnConfiguring method calls UseNpgsql with a PostgreSQL connection string containing a host, username, password, and database. The provider connects through its underlying Npgsql dependency.
For a write, the application adds a Blog to ctx.Blogs and calls SaveChangesAsync. EF Core processes the entity change and asks the provider to execute the corresponding persistence operation. For a read, the application calls Where with a LINQ predicate and then materializes the query with ToListAsync. The application does not need to load all rows and filter them manually in C#.
The sample model contains only an integer Id and a string Name. It does not demonstrate inheritance, owned entities, concurrency tokens, lazy loading, interceptors, custom conversions, or large query result handling. Those cases should not be inferred from the simplicity of the Blog example.
PostgreSQL-specific behavior extends beyond basic inserts and queries. The README lists JSON, array, and range columns among the supported capabilities. It also identifies separate plugins for PostGIS through Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite and for NodaTime types through Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime. These features explain why selecting a PostgreSQL provider can change application mappings compared with a provider-independent design.
The repository contains src and test directories, along with solution, build, and package configuration files. That layout separates provider implementation from its tests. The README does not document a test command or its service requirements, so no test invocation can be presented as a verified setup step.
Installing the provider and running the documented first use
The README identifies Npgsql.EntityFrameworkCore.PostgreSQL as a NuGet package and links to its NuGet package page. It does not give a dotnet add package command. Obtain the package from the linked NuGet page and select a version whose EF Core compatibility matches the application. The README does not publish a version matrix in its quick-start example.
The documented first use configures a DbContext with UseNpgsql, inserts a Blog, saves it, and retrieves records whose Name starts with a character. The following is the README's C# example:
await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();
ctx.Blogs.Add(new() { Name = "FooBlog" });
await ctx.SaveChangesAsync();
var fBlogs = await ctx.Blogs.Where(b => b.Name.StartsWith("F")).ToListAsync();The context and entity definitions in the same example supply the DbSet, mapping properties, and connection string:
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; }
}The example contains placeholders for the PostgreSQL server and credentials. Replace them for the target environment and do not store production passwords in source control. The README does not name a particular secret provider or deployment configuration.
The first two asynchronous calls require special care. EnsureDeletedAsync requests deletion of the configured database, while EnsureCreatedAsync creates it when absent. Run this sequence only against a disposable or explicitly approved database. The README does not define printed output, so a completed first use should be judged by whether SaveChangesAsync and ToListAsync complete without a provider or connection error.
PostgreSQL types and separately versioned plugins
The provider exposes PostgreSQL-specific capabilities through EF Core. The README specifically names query support for JSON, array, and range columns. These types belong to PostgreSQL's data model, and the provider gives an EF Core application access to them without requiring every query to be expressed as raw PostgreSQL SQL. The README does not provide mapping or query examples for each type, so production schemas require additional provider documentation.
Two related packages cover extensions that are not part of the basic example. Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite works with PostgreSQL PostGIS, while Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime provides date and time types for PostgreSQL. Separate packages keep unrelated dependencies out of applications that do not need spatial data or NodaTime.
That separation also adds a maintenance decision. A GIS application may require NetTopologySuite integration and its package compatibility. An application with substantial temporal modeling may consider NodaTime. A basic Blog-style model has no documented need for either plugin. Adding optional packages without a data requirement would enlarge the upgrade surface for no stated benefit.
The README does not document plugin setup, supported versions, migration changes, or the full range of PostgreSQL types handled by the provider. It points readers to the Npgsql site for additional information. This makes the repository suitable for identifying the provider's extensions, but not for inventing production configuration that the README does not contain.
Schema commands and application migration boundaries
The README sample calls EnsureDeletedAsync before EnsureCreatedAsync. This sequence is appropriate only when deleting and recreating the configured PostgreSQL database is intended. It is not a substitute for a production schema update process. Copying the sample into application startup could remove data from an accidentally selected database.
The repository description identifies the project as an EF Core provider, and the README directs readers to EF Core documentation for general ORM behavior. However, the quick-start section does not explain migrations, baseline creation, existing PostgreSQL schema adoption, or production deployment. Those workflows should not be invented from the two destructive or recreating database calls.
Connection behavior is also only lightly covered. The sample uses await using for the DbContext and passes a complete connection string to UseNpgsql. It does not document retry policies, transient fault behavior, pooling, or secret delivery. Npgsql is identified as the underlying ADO.NET provider, but the README does not state how this package configures those concerns.
A responsible first evaluation therefore needs a disposable PostgreSQL database. Before touching an existing environment, inspect the application's intended schema process and verify the database named by the connection string. The provider can sit inside that process, but the quick-start example does not define its production policy.
Release history, license, and upgrade responsibilities
The repository is not archived, and its last push was on 2026-10-16. The recent release list includes v10.0.3 from 2026-09-14, v10.0.2 from 2026-05-27, and v10.0.0 from 2025-11-22. These records show recent repository and package activity, although the README does not associate each package version with a specific EF Core major version.
Package selection requires direct compatibility verification. This repository contains Directory.Packages.props, global.json, a solution, and build configuration, but the README does not state the values needed to construct a supported.NET and EF Core version matrix. The package metadata should therefore be checked before upgrading the application.
The repository license is identified as PostgreSQL. Teams must review the repository LICENSE file for the applicable terms. They should also review the licenses of separate dependencies and plugins selected for an application. The README does not provide legal analysis, and a package name should not be treated as a substitute for reading its license.
An upgrade can affect the core provider, DbContext configuration, query mappings, and optional NetTopologySuite or NodaTime packages. The release history confirms published versions but does not guarantee compatibility across every combination. Version alignment and the behavior of the application's existing PostgreSQL queries are the first project-specific upgrade checks.
Npgsql.EntityFrameworkCore.PostgreSQL versus portable EF Core designs
A direct alternative is an EF Core design restricted to database-provider-independent mappings and queries. Such a design can preserve more freedom to consider another relational database. Its cost is the loss of direct access to PostgreSQL-specific features that Npgsql.EntityFrameworkCore.PostgreSQL documents, including JSON, array, range, PostGIS, and NodaTime integration.
Another approach is using Npgsql directly rather than adding the EF Core provider. That approach supports explicit lower-level database access through the ADO.NET layer, but it does not provide the DbContext and LINQ programming model shown in the README. It also means the application must handle more database operations explicitly rather than relying on EF Core's change tracking and query abstractions.
Npgsql.EntityFrameworkCore.PostgreSQL is the stronger candidate when EF Core is already established and PostgreSQL is a deliberate platform choice. A provider-independent design is more defensible when cross-database portability outweighs the need for PostgreSQL-specific mappings. Direct Npgsql usage is more appropriate for applications that prioritize explicit SQL and do not depend on EF Core.
The project does not claim higher performance or lower operating cost for PostgreSQL. Its documented purpose is narrower: connecting EF Core to PostgreSQL through Npgsql and exposing selected PostgreSQL capabilities.
Editorial conclusion
Adopt Npgsql.EntityFrameworkCore.PostgreSQL when the application uses .NET, EF Core, PostgreSQL, and needs PostgreSQL-specific data types or related plugins. Do not choose it for another database or an EF Core version outside the selected package's supported range. Verify package compatibility, connection security, optional plugin requirements, and schema operations first. On that basis, this package is a direct fit for PostgreSQL-backed EF Core applications rather than a general-purpose database abstraction.
Frequently asked questions
What is Npgsql.EntityFrameworkCore.PostgreSQL used for?
It is the open source Entity Framework Core provider for PostgreSQL. It lets a .NET application use EF Core and LINQ with PostgreSQL through the underlying Npgsql ADO.NET provider.
How do I install Npgsql.EntityFrameworkCore.PostgreSQL?
The README links to the Npgsql.EntityFrameworkCore.PostgreSQL package on NuGet. It does not provide a dotnet add package command or a complete EF Core compatibility matrix, so package compatibility must be verified before installation.
Which PostgreSQL-specific features does the provider support?
The README explicitly lists JSON, array, and range column queries. It also links separate packages for PostGIS support through Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite and NodaTime support through Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.
Does the provider depend on Npgsql?
Yes. The README states that Npgsql.EntityFrameworkCore.PostgreSQL is built on top of Npgsql, the underlying ADO.NET provider for PostgreSQL.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/npgsql-efcore-pg)Star history chart for your README
[](https://hysenlabs.com/projects/npgsql-efcore-pg)Was this useful?