dotnet / dotnet/aspnetcore

Error if I query the DbSet of IdentityDbContext.UserPasskeys

Open
#64,334 4 comments 1 reaction 1 assignee Assigned to @Copilot View on GitHub
area-identity Docs
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

If I create a IdentityDbContext and try to read the DBSet for the UserPasskeys I get this error

```
System.InvalidOperationException : Cannot create a DbSet for 'IdentityUserPasskey' because this type is not included in the model for the context.

Stack Trace: 
InternalDbSet`1.get_EntityType()
InternalDbSet`1.CheckState()
InternalDbSet`1.get_EntityQueryable()
IEnumerable.GetEnumerator()
List`1.ctor(IEnumerable`1 collection)
Enumerable.ToList[TSource](IEnumerable`1 source)
UnitTest1.Test1() line 17
MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
```

All the other entities can be read

### Expected Behavior

I would expect to read the query

### Steps To Reproduce

I created a test project in the [https://github.com/luizfbicalho/error-passkey-aspnet-identity](https://github.com/luizfbicalho/error-passkey-aspnet-identity)

tried with 3 different scenarios , one test for each, and one test that works for the others dbSets

### Exceptions (if any)

System.InvalidOperationException : Cannot create a DbSet for 'IdentityUserPasskey' because this type is not included in the model for the context.

Stack Trace: 
InternalDbSet`1.get_EntityType()
InternalDbSet`1.CheckState()
InternalDbSet`1.get_EntityQueryable()
IEnumerable.GetEnumerator()
List`1.ctor(IEnumerable`1 collection)
Enumerable.ToList[TSource](IEnumerable`1 source)
UnitTest1.Test1() line 17
MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

### .NET Version

.NET 10

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.