Couchbase’s new EF Core provider opens the door to some powerful .NET integrations: even ones traditionally tied to relational databases. This post walks through how Identity, GraphQL, and OData all work with Couchbase.
In this post, I’ll walk through three advanced EF Core integrations that I have successfully tested with Couchbase:
- ASP.NET Core Identity
- GraphQL (via Hot Chocolate)
- OData
Note: These integrations are based on limited testing and are not officially supported (yet). Your mileage may vary, but so far, they show a lot of promise.
ASP.NET Core Identity
Microsoft.AspNetCore.Identity.EntityFrameworkCore provides a plug-and-play authentication and user management system for ASP.NET apps.
Couchbase’s EF Core provider works well with it. The only caveat is that you’ll need to make sure the proper collections exist first (like AspNetUsers, AspNetRoles, etc).
Note: You must create the following collections in advance: AspNetUsers, AspNetRoles, AspNetUserRoles, AspNetUserClaims, AspNetUserLogins, AspNetUserTokens, AspNetRoleClaims.
Example EF setup
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
public class AppDbContext : IdentityDbContext<ApplicationUser< { public AppDbContext(DbContextOptions<AppDbContext< 옵션) : base(옵션) { } protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity<ApplicationUser<().ToCouchbaseCollection(this, “AspNetUsers”); builder.Entity<IdentityRole<().ToCouchbaseCollection(this, “AspNetRoles”); builder.Entity<IdentityUserRole<string>>().ToCouchbaseCollection(this, “AspNetUserRoles”); builder.Entity<IdentityUserClaim<string>>().ToCouchbaseCollection(this, “AspNetUserClaims”); builder.Entity<IdentityUserLogin<string>>().ToCouchbaseCollection(this, “AspNetUserLogins”); builder.Entity<IdentityUserToken<string>>().ToCouchbaseCollection(this, “AspNetUserTokens”); builder.Entity<IdentityRoleClaim<string>>().ToCouchbaseCollection(this, “AspNetRoleClaims”); } } public class ApplicationUser : IdentityUser { } |
MVC auth example
Here’s an ASP.NET Core MVC controller with registration, login, and logout, as well as a custom role:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
public class AuthController : Controller { private readonly UserManager<ApplicationUser< _userManager; private readonly SignInManager<ApplicationUser< _signInManager; private readonly RoleManager<IdentityRole< _roleManager; public AuthController(UserManager<ApplicationUser< userManager, SignInManager<ApplicationUser< signInManager, RoleManager<IdentityRole< roleManager) { _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; } public IActionResult Register() =< View(); [HttpPost] public 비동기 Task<IActionResult< Register(RegisterModel model) { 만약 (!ModelState.IsValid) 반환 View(model); 변수 user = 새로운 ApplicationUser { UserName = model.이메일, 이메일 = model.이메일 }; 변수 result = await _userManager.CreateAsync(user, model.Password); 만약 (result.Succeeded) { 변수 roleName = “CustomRole”; 만약 (!await _roleManager.RoleExistsAsync(roleName)) await _roleManager.CreateAsync(새로운 IdentityRole(roleName)); await _userManager.AddToRoleAsync(user, roleName); await _signInManager.SignInAsync(user, isPersistent: false); 반환 RedirectToAction(“Index”, “Home”); } foreach (변수 error in result.Errors) ModelState.AddModelError(“”, error.Description); 반환 View(model); } public IActionResult Login() =< View(); [HttpPost] public 비동기 Task<IActionResult< Login(LoginModel model) { 만약 (!ModelState.IsValid) 반환 View(model); 변수 result = await _signInManager.PasswordSignInAsync(model.이메일, model.Password, false, false); 만약 (result.Succeeded) 반환 RedirectToAction(“Index”, “Home”); ModelState.AddModelError(“”, “Invalid login attempt.”); 반환 View(model); } public 비동기 Task<IActionResult< Logout() { await _signInManager.SignOutAsync(); 반환 RedirectToAction(“Index”, “Home”); } } |
The data follows the standard Identity structure, stored in a Couchbase document. For example, a document in AspNetUser collection:

GraphQL with Hot Chocolate
Hot Chocolate is a popular GraphQL server for .NET. It can integrate with EF Core, leaning on the LINQ capabilities of the provider (which Couchbase has). This means that GraphQL queries are translated to LINQ, which is then translated to Couchbase SQL++.
Setup
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public class WidgetQuery { [UseFiltering] [UseSorting] public IQueryable<Widget< GetWidgets([Service] WidgetDbContext dbContext) =< dbContext.Widgets; } // Program.cs: builder.서비스 .AddGraphQLServer() .AddQueryType<WidgetQuery<() .AddFiltering() .AddSorting() .AddProjections(); app.MapGraphQL(); |
Example usage
- Go to /graphql in browser (this brings up a web interface)

- Try a query like this:
|
1 2 3 4 5 6 7 8 9 |
query { widgets(where: { name: { contains: “foo” } }, order: { createdDt: DESC }) { id name price numInStock createdDt } } |
This will return results like:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{ “data”: { “widgets”: [ { “id”: “b5c494fe-135f-4f01-bf12-6e4ad1eee829”, “name”: “foobar”, “price”: 1.99, “numInStock”: 50, “createdDt”: “2025-06-18T18:11:19.149Z” } ] } } |
Tips
- GraphQL queries need to match your GSI indexes (it’s just SQL++ queries under the hood).
- You can use cover indexes and other SQL++ indexes to improve performance.
OData
Microsoft.AspNetCore.OData exposes your EF Core data as OData endpoints, making it easy to connect tools like Excel, Power BI, and Tableau to Couchbase.
Sample program.cs
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
builder.서비스.AddControllersWithViews() .AddOData(opt =< { 변수 odataBuilder = 새로운 ODataConventionModelBuilder(); odataBuilder.EntitySet<Widget<(“Widgets”); opt.AddRouteComponents(“odata”, odataBuilder.GetEdmModel()) .Filter() .OrderBy() .Select() .Expand() .Count() .SetMaxTop(100); }); |
Controller
|
1 2 3 |
[HttpGet(“/odata/Widgets”)] [EnableQuery] public IQueryable<Widget< GetOData() =< _context.Widgets; |
Example OData queries
- https://localhost:7037/odata/Widgets?$filter=price gt 1&$orderby=name
- https://localhost:7037/odata/Widgets?$select=name,price&$top=10

Note: Make sure your EF Core LINQ queries can be translated to SQL++ and that any filtered/sorted fields are indexed in Couchbase.
Wrapping up
All of these integrations are backed by EF Core—and now, with Couchbase support, you can take full advantage of them in your code. Whether you’re building secure web applications, GraphQL APIs or integrating with BI tools, The EF Core and Couchbase combo makes it possible.
Curious to see more? Let us know what integrations you’d like to explore next!

댓글 남기기
댓글을 달기 위해서는 로그인해야합니다.