C
C#•3w ago
Zoli

MongoDB.Driver.Linq.ExpressionNotSupportedException: ' Expression not supported: i.ToClaim()

I have implemented identity in ASP.NET Core, with features like registration and login working properly, including returning a JWT. Now, I want to migrate the system to MongoDB with using MongoDB.EntityFrameworkCore package. During testing, I can successfully register a new user, and the user appears in the collection. However, when I attempt to log in, I encounter the following exception. All I did
builder.Services.AddDbContext<AppDbContext>(ops => ops.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddDbContext<AppDbContext>(ops => ops.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
to
builder.Services.AddDbContext<AppDbContext>(options =>

options.UseMongoDB(connectionUri, databaseName)
);
builder.Services.AddDbContext<AppDbContext>(options =>

options.UseMongoDB(connectionUri, databaseName)
);
in the AppDbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().ToCollection("users");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().ToCollection("users");
}
What can cause this? The registration works as expected but when login throws this.
No description
5 Replies
Sehra
Sehra•3w ago
what does the CustomMapIdentityApi look like?
Zoli
ZoliOP•3w ago
It is actually an extension for IEndpointRouteBuilder.
No description
Sehra
Sehra•3w ago
GitHub
Cleanup in Identity tests · dotnet/aspnetcore@a86a811
Fixes #10671 by using updated EF API Fixes #5812 so tests are re-enabled for PRs Also part of #10668 since one of the changed EF queries is now working Finally, I removed all remaining platform sk...
Sehra
Sehra•3w ago
efcore got a fix to handle it, but same has not been done by the mongodb developers
Zoli
ZoliOP•3w ago
Ohh thanks, I wouldn't find this for sure 😄 agree it must be that the reason.

Did you find this page helpful?