This sample project tests the support for .NET 10 ASP.NET Core Identity PassKeys with Pomelo.EntityFrameworkCore.MySql.
ASP.NET Core Identity in .NET 10 introduced PassKey support (WebAuthn credentials) as part of the Identity Schema Version 3. The PassKey implementation requires the IdentityUserPasskey<TKey> entity, which contains an IdentityPasskeyData property that must be stored as JSON using EF Core's .ToJson() method.
The IdentityPasskeyData class contains properties with non-primitive types, specifically string[] (the Transports property), which was reported as not working with MySQL providers in dotnet/aspnetcore#64939.
✅ All tests passed successfully!
- Database Creation: The PassKey table (
AspNetUserPasskeys) was created successfully - Column Type: The
Datacolumn was created aslongtext(MariaDB's JSON implementation) - Insert Operation: PassKey records with complex data including
string[]arrays were inserted successfully - Read Operation: PassKey records were retrieved correctly with all data intact
- Array Handling: The
string[] Transportsproperty was correctly serialized to JSON and deserialized back - JSON Validation: The stored JSON data is valid and can be queried using MariaDB's JSON functions
=== Testing PassKey Support with Pomelo EF Core MySQL ===
1. Testing database connection...
✓ Deleted existing dat
672E
abase (if any)
2. Creating database with Identity schema including PassKeys (Version 3)...
✓ Database created successfully!
3. Checking if AspNetUserPasskeys table was created...
✓ AspNetUserPasskeys table exists!
4. Checking Data column type in AspNetUserPasskeys...
✓ Column: Data, Type: longtext, Full Type: longtext
5. Testing insert of a PassKey record with complex data...
✓ Created test user: testuser@example.com
✓ PassKey record inserted successfully!
6. Reading back the PassKey record...
✓ Retrieved PassKey: dGVzdC1jcmVkZW50aWFsLWlkLTEyMzQ1
✓ Name: Test PassKey
✓ SignCount: 0
✓ Transports: [usb, nfc, ble]
✓ Transport count: 3
✓ Transports array correctly stored and retrieved!
7. Checking raw JSON data in database...
Raw JSON in database:
{"AttestationObject":"...", "ClientDataJson":"...", "Transports":["usb","nfc","ble"], ...}
=== ✓ ALL TESTS PASSED! ===
Pomelo.EntityFrameworkCore.MySql successfully supports .NET 10 Identity PassKeys!
The ToJson() method correctly handles complex types including string[] arrays. The implementation uses MySqlStructuralJsonTypeMapping which properly converts between MySQL's JSON storage (as longtext) and EF Core's MemoryStream representation.
To use PassKeys with Pomelo.EntityFrameworkCore.MySql:
- Configure your DbContext to inherit from
IdentityDbContextwith the PassKey type:
public class ApplicationDbContext : IdentityDbContext<
IdentityUser,
IdentityRole,
string,
IdentityUserClaim<string>,
IdentityUserRole<string>,
IdentityUserLogin<string>,
IdentityRoleClaim<string>,
IdentityUserToken<string>,
IdentityUserPasskey<string>>
{
// ...
}- Configure the PassKey entity in
OnModelCreating:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<IdentityUserPasskey<string>>(b =>
{
b.HasKey(p => p.CredentialId);
b.ToTable("AspNetUserPasskeys");
b.Property(p => p.CredentialId).HasMaxLength(1024);
b.OwnsOne(p => p.Data).ToJson(); // This is the key configuration!
});
}- Use Pomelo as your database provider:
services.AddDbContext<ApplicationDbContext>(options =>
options.UseMySql(connectionString, serverVersion)
);-
Ensure MariaDB 11.6.2 (or MySQL 8.0+) is running:
docker run --name mariadb_test -e MYSQL_ROOT_PASSWORD=Password12! -p 127.0.0.1:3306:3306 -d mariadb:11.6.2 -
Build and run the test:
cd samples/PassKeyTest dotnet run
- Storage: MariaDB stores JSON as
longtextwith JSON validation constraints - Serialization: Pomelo uses
MySqlStructuralJsonTypeMappingto handle JSON columns - Reader/Writer: The implementation reads strings from the database and converts them to
MemoryStreamfor EF Core's JSON handling - Arrays: Non-primitive types like
string[]are correctly serialized/deserialized as JSON arrays
- .NET 10.0.101
- Pomelo.EntityFrameworkCore.MySql (current version)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore 10.0.1
- MariaDB 11.6.2
- MySqlConnector 2.5.0