The Couchbase EF Core Provider is now generally available. This release brings the power of Entity Framework Core to Couchbase, allowing .NET developers to work with Couchbase using familiar EF Core patterns.

What is the Couchbase EF Core provider?

Entity Framework Core (EF Core) is a popular O/RM that simplifies database access for .NET applications. It allows developers to work with data using C# objects and LINQ queries instead of writing raw database queries. EF Core enables integration with various databases, providing automatic change tracking, transactions, and a familiar DbContext API. It’s a familiar interface that developers can use to save time and integrate with many frameworks and database-adjacent libraries.

The Couchbase EF Core Provider enables developers to use Entity Framework Core with Couchbase Server and Couchbase Capella (now available with a perpetual free tier). With this provider, you can work with Couchbase documents as if they were relational entities, using Linq queries, DbContext, and change tracking.

Getting started

To install the Couchbase EF Core Provider, add the NuGet package:

Example: using EF Core with Couchbase

Here’s a simple “shopping cart” example of how to set up and use the Couchbase EF Core Provider with a shopping cart model.

Define Your Entity Models

Create a DbContext for Couchbase

This arrangement assumes that you have created a bucket in Couchbase called Shopping, which contains a scope called Ecommerce, which contains collections Items and Carts.

Also, note that logging is optional, but it’s a good idea to turn it on to help identify any issues that may come up.

Insert and Query Data

Here’s an example of what the documents in Couchbase will look like after insertion:

What works in the GA release?

The entire functionality of EF Core is very, very large. Being able to handle every possible Linq statement, for instance, is nearly impossible, even for mature EF Core providers like SQL Server. However, this release supports many core EF Core capabilities, including:

LINQ support – Translates LINQ queries to Couchbase SQL++.
Basic CRUD operations – Insert, update, and delete work as expected.
Change tracking – Entities are tracked for efficient updates.

Also note that using Async methods is required. Couchbase’s .NET SDK is completely asynchronous. If you try to use a non-async method, you will get a runtime error along the lines of Couchbase EF Core Database Provider does not support synchronous I/O.

Known limitations

While this is a significant milestone, some features are still a work in progress, including:

Denormalization – Nesting collections inside documents (e.g., storing Items inside Cart as a single JSON document) is not yet supported.
Eager Loading.Include() statements may not work as expected.
SQL++ Function Support – Some SQL++ functions like META, RYOW, etc., are not fully implemented.
Transactions – Not yet supported in this release.

Join the conversation!

We want your feedback! Help shape the future of the Couchbase EF Core Provider:

What’s next?

This release is just the beginning! We’re actively working on building out this EF Core implementation. Your feedback will help to prioritize functionality.

Try it out today and let us know what you think. Happy coding!



Author

Posted by Matthew Groves

Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.

Leave a reply