Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I tried the new minimal API code generated validation. Everytime I call any endpoint, I have this exception.
Here are the versions I use
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0-preview.3.25172.1" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0-preview.3.25172.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.0-preview.3.25171.6" />
The test is done in a dev container, using mcr.microsoft.com/dotnet/sdk:10.0.100-preview.3
2025-05-02 10:28:44.047 +00:00 [Error] Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware - An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Property 'Microsoft.EntityFrameworkCore.Storage.IDatabaseFacadeDependenciesAccessor.Dependencies' not found on type 'DatabaseFacade'.
at Microsoft.AspNetCore.Http.Validation.ValidatablePropertyInfo.ValidateAsync(Object value, ValidateContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Validation.ValidatableTypeInfo.ValidateAsync(Object value, ValidateContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Validation.ValidatablePropertyInfo.ValidateAsync(Object value, ValidateContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Validation.ValidatableTypeInfo.ValidateAsync(Object value, ValidateContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Validation.ValidatableTypeInfo.ValidateAsync(Object value, ValidateContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Validation.ValidatableParameterInfo.ValidateAsync(Object value, ValidateContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Validation.ValidationEndpointFilterFactory.<>c__DisplayClass0_0.<<Create>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Http.RequestDelegateFactory.<ExecuteValueTaskOfObject>g__ExecuteAwaited|129_0(ValueTask`1 valueTask, HttpContext httpContext, JsonTypeInfo`1 jsonTypeInfo)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Expected Behavior
No exception occurs
Steps To Reproduce
- add
builder.Services.AddValidation();
in startup - add
<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.Http.Validation.Generated</InterceptorsNamespaces>
in the csproj - Implement a handler that looks like
private static async Task<List<TodoItem>> Handle(ApplicationDbContext dbContext)
{
return await dbContext.TodoItems.ToListAsync();
}
- Call the handler
Exceptions (if any)
System.InvalidOperationException: Property 'Microsoft.EntityFrameworkCore.Storage.IDatabaseFacadeDependenciesAccessor.Dependencies' not found on type 'DatabaseFacade'.
.NET Version
10.0.100-preview.3.25201.16
Anything else?
No response