https://github.com/cockroachdb/efcore.pg.cockroach
https://github.com/cockroachdb/efcore.pg.cockroach
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cockroachdb/efcore.pg.cockroach
- Owner: cockroachdb
- License: other
- Created: 2023-10-15T09:46:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-15T16:09:31.000Z (about 1 year ago)
- Last Synced: 2025-06-13T14:02:32.081Z (13 days ago)
- Language: C#
- Homepage:
- Size: 698 KB
- Stars: 4
- Watchers: 49
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cockroach extension for Npgsql.EntityFrameworkCore.PostgreSQL
Npgsql.EntityFrameworkCore.CockroachDB is an extension library to add compatibility for CockroachDB to the open source EF Core provider for PostgreSQL. It allows you to interact with CockroachDB 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.EntityFrameworkCore.PostgreSQL](https://github.com/npgsql/efcore.pg).
Here's a quick sample to get you started:
```csharp
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 Blogs { get; set; }protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseNpgsql(@"Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase")
.UseCockroach();
}public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
}
```