Get Started
| Product | Versions |
|---|---|
| .NET |
README
EF Core Couchbase DB Provider
This database provider allows Entity Framework Core to be used with Couchbase Database. The provider is maintained as part of the Couchbase EFCore Project.
It is strongly recommended to familiarize yourself with the Couchbase Database documentation before reading this section. The EF Core Couchbase Db Provider, works with Couchbase Server and Couchbase Capella DBaaS.
Install
Install the Couchbase.EntityFrameworkCore NuGet package.
.NET Core CLI or Jet Brains Rider IDE
dotnet add package Couchbase.EntityFrameworkCore
Visual Studio
Install-Package Couchbase.EntityFrameworkCore
Control casing
This is required as the Couchbase defaults to Camel-Casing but EF Core defaults to Pascal-Casing for generated SQL:
Install-Package EFCore.NamingConventions
Without this queries will likely return back empty results as the JSON is case sensitive.
Get Started
You can view this article's sample on GitHub
As for other providers the first step is to call UseCouchbase:
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseCouchbase(new ClusterOptions()
.WithCredentials("Administrator", "password")
.WithConnectionString("couchbase://localhost"),
couchbaseDbContextOptions =>
{
couchbaseDbContextOptions.Bucket = "OrdersDB";
couchbaseDbContextOptions.Scope = "_default";
})
.UseCamelCaseNamingConvention();
In this example Order is a simple entity with a reference to the owned type StreetAddress.
public class Order
{
public int Id { get; set; }
public int? TrackingNumber { get; set; }
public string PartitionKey { get; set; }
public StreetAddress ShippingAddress { get; set; }
}
public class StreetAddress
{
public string Street { get; set; }
public string City { get; set; }
}
Saving and querying data follows the normal EF pattern:
using (var context = new OrderContext())
{
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
context.Add(
new Order
{
Id = 1, ShippingAddress = new StreetAddress { City = "London", Street = "221 B Baker St" }, PartitionKey = "1"
});
await context.SaveChangesAsync();
}
using (var context = new OrderContext())
{
var order = await context.Orders.FirstAsync();
Console.WriteLine($"First order will ship to: {order.ShippingAddress.Street}, {order.ShippingAddress.City}");
Console.WriteLine();
}
- The Contoso University web app code
- Contoso University sample documentation
- Getting started - in more detail
Couchbase DB options
There exists options for both the Couchbase SDK which the Couchbase EF Core DB Provider uses and for the provider itself.
- ClusterOptions settings
- Couchbase EF Core DB Provider settings
What works:
- Basic projections/queries
- Some SQL++ functions - COUNT, CONTAINS, etc
- Basic CRUD and change tracking
What doesn't work
- Eager Loading
- Most all SQL++ functions
- Value generation
- META, RYOW, etc
- Sync IO Methods
- Lots...it's a WIP
Documentation
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
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.