-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Hi,
working on a side project I found out that calling Set.FindAsync(key, cancellationToken) throws this error:
Entity type 'IntKey' is defined with a single key property, but 2 values were passed to the 'DbSet.Find' method.
on version 2.1.0-rc1-final
Just removing the cancellationToken parameter from the FindAsync call fixes the problem, so I decided to check if it's reproing on the current dev branch thus I have extended the FindTestBase class to add a new FindAsync overload because I wasn't able to find an existing test using FindAsync and passing in a cancellationToken.
The added overload looks like the following:
FindAsync<TEntity>(DbContext context, object[] keyValues, CancellationToken cancellationToken)
this is the added test:
[Fact]
public virtual async Task Find_int_key_from_store_async_with_cancellation_token()
{
using (var context = CreateContext())
{
Assert.Equal("Smokey", (await FindAsync<IntKey>(context, 77, CancellationToken.None)).Foo);
}
}and the code fails on current dev with the following exception:
System.ArgumentException : Entity type 'IntKey' is defined with a single key property, but 2 values were passed to the 'DbSet.Find' method.
Stack Trace:
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.FindTracked(Object[] keyValues, IReadOnlyList`1& keyProperties) in C:\Code\EntityFrameworkCore\src\EFCore\Internal\EntityFinder.cs:line 259
at Microsoft.EntityFrameworkCore.Internal.EntityFinder`1.Microsoft.EntityFrameworkCore.Internal.IEntityFinder.FindAsync(Object[] keyValues, CancellationToken cancellationToken) in C:\Code\EntityFrameworkCor
e\src\EFCore\Internal\EntityFinder.cs:line 102
at Microsoft.EntityFrameworkCore.DbContext.FindAsync(Type entityType, Object[] keyValues) in C:\Code\EntityFrameworkCore\src\EFCore\DbContext.cs:line 1367
at Microsoft.EntityFrameworkCore.FindSqliteTest.FindSqliteTestNonGeneric.FindAsync[TEntity](DbContext context, Object[] keyValues) in C:\Code\EntityFrameworkCore\test\EFCore.Sqlite.FunctionalTests\FindSqlit
eTest.cs:line 62
at Microsoft.EntityFrameworkCore.FindTestBase`1.Find_int_key_from_store_async_with_cancellation_token() in C:\Code\EntityFrameworkCore\src\EFCore.Specification.Tests\FindTestBase.cs:line 395
This smells like an issue to me and I'm looking into it, just created this issue for letting you know guys.
I wasn't able to find any similar issue, if it's a dupe, feel free to close it