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
참고: 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).
참고: 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 |
공공의 class AppDbContext : IdentityDbContext<ApplicationUser< { 공공의 AppDbContext(DbContextOptions<AppDbContext< 옵션) : base(옵션) { } protected override 무효 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”); } } 공공의 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 |
공공의 class AuthController : Controller { private readonly UserManager<ApplicationUser< _userManager; private readonly SignInManager<ApplicationUser< _signInManager; private readonly RoleManager<IdentityRole< _roleManager; 공공의 AuthController(UserManager<ApplicationUser< userManager, SignInManager<ApplicationUser< signInManager, RoleManager<IdentityRole< roleManager) { _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; } 공공의 IActionResult Register() =< View(); [HttpPost] 공공의 비동기 Task<IActionResult< Register(RegisterModel 모델) { 만약 (!ModelState.IsValid) 반환 View(모델); 변수 user = 새로운 ApplicationUser { UserName = 모델.이메일, 이메일 = 모델.이메일 }; 변수 result = await _userManager.CreateAsync(user, 모델.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(모델); } 공공의 IActionResult Login() =< View(); [HttpPost] 공공의 비동기 Task<IActionResult< Login(LoginModel 모델) { 만약 (!ModelState.IsValid) 반환 View(모델); 변수 result = await _signInManager.PasswordSignInAsync(모델.이메일, 모델.Password, false, false); 만약 (result.Succeeded) 반환 RedirectToAction(“Index”, “Home”); ModelState.AddModelError(“”, “Invalid login attempt.”); 반환 View(모델); } 공공의 비동기 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 |
공공의 class WidgetQuery { [UseFiltering] [UseSorting] 공공의 IQueryable<Widget< GetWidgets([Service] WidgetDbContext dbContext) =< dbContext.Widgets; } // Program.cs: builder.서비스 .AddGraphQLServer() .AddQueryType<WidgetQuery<() .AddFiltering() .AddSorting() .AddProjections(); 앱.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 |
질의 { widgets(where: { name: { contains: “foo” } }, order: { createdDt: DESC }) { 아이디 name 가격 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] 공공의 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

참고: 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!

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