Entity Framework Core provider for PostgreSQL
Find a file
Shay Rojansky 9b84f9e8de
Some checks are pending
Build / build (Release, windows-2022, 15) (push) Waiting to run
Build / build (Debug, ubuntu-22.04, 15) (push) Waiting to run
Build / build (Release, ubuntu-22.04, 11) (push) Waiting to run
Build / build (Release, ubuntu-22.04, 12) (push) Waiting to run
Build / build (Release, ubuntu-22.04, 13) (push) Waiting to run
Build / build (Release, ubuntu-22.04, 14) (push) Waiting to run
Build / build (Release, ubuntu-22.04, 15) (push) Waiting to run
Build / build (Release, windows-2022, 11) (push) Waiting to run
Build / build (Release, windows-2022, 12) (push) Waiting to run
Build / build (Release, windows-2022, 13) (push) Waiting to run
Build / build (Release, windows-2022, 14) (push) Waiting to run
Build / publish-ci (push) Blocked by required conditions
Build / release (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Sync to 8.0.0-rc.1.23419.6 (#2868)
2023-09-13 14:57:34 +03:00
.build Docker-less Github Actions 2020-02-23 15:19:03 +02:00
.github Sync to 8.0.0-rc.1.23419.6 (#2868) 2023-09-13 14:57:34 +03:00
src Sync to 8.0.0-rc.1.23417.21 (#2857) 2023-08-29 18:01:44 +02:00
test Sync to 8.0.0-rc.1.23417.21 (#2857) 2023-08-29 18:01:44 +02:00
tools Annotate for nullability (#1764) 2021-03-16 13:48:41 +00:00
.editorconfig Code cleanup (#2154) 2021-12-16 12:53:59 +00:00
.gitattributes Initial import from Npgsql repository 2016-04-14 16:07:10 +03:00
.gitignore Sync azp configuration 2019-07-30 22:28:02 -04:00
Directory.Build.props Sync to EF 8.0.0-preview.7 (#2845) 2023-08-18 15:53:11 +02:00
Directory.Packages.props Sync to 8.0.0-rc.1.23419.6 (#2868) 2023-09-13 14:57:34 +03:00
EFCore.PG.sln Sync to 8.0.0-rc.1.23419.6 (#2868) 2023-09-13 14:57:34 +03:00
EFCore.PG.sln.DotSettings Sync to 8.0.0-rc.1.23417.21 (#2857) 2023-08-29 18:01:44 +02:00
global.json Sync to 8.0.0-rc.1.23419.6 (#2868) 2023-09-13 14:57:34 +03:00
LICENSE Bump license year to 2021 2021-02-18 17:34:24 +01:00
Npgsql.snk Initial import from Npgsql repository 2016-04-14 16:07:10 +03:00
NuGet.config Sync EF Core to 8.0.0-preview.2.23128.3 (#2676) 2023-03-06 14:54:42 +00:00
postgresql.png Icon embedded into the NuGet package 2019-09-25 18:03:59 +03:00
QueryBaseline.cs Follow up to #753. Explicitly cast config to regconfig. 2019-03-14 21:28:24 +02:00
README.md Fix link to NuGet package in README 2022-09-05 16:31:59 +03:00

Npgsql Entity Framework Core provider for PostgreSQL

stable next patch daily builds (vnext) build gitter

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.