-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequence contains no elements running in-memory query with class key #26238
Comments
Example of test that fails: [ConditionalFact]
public virtual void Can_query_and_update_owned_entity_with_int_bare_class_key()
{
using (var context = CreateContext())
{
context.Add(new OwnerBareIntClassKey(new(1), new(77)));
context.SaveChanges();
}
using (var context = CreateContext())
{
var owner = context.Set<OwnerBareIntClassKey>().Single(o => o.Id.Equals(new BareIntClassKey(1)));
Assert.Equal(77, owner.Owned.Position);
owner.Owned = new(88);
context.SaveChanges();
}
using (var context = CreateContext())
{
var owner = context.Set<OwnerBareIntClassKey>().Find(new BareIntClassKey(1));
Assert.Equal(88, owner.Owned.Position);
}
} Exception thrown: System.InvalidOperationException
Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at lambda_method140(Closure )
at Microsoft.EntityFrameworkCore.InMemory.Query.Internal.InMemoryQueryExpression.ResultEnumerable.GetEnumerator() in C:\dotnet\efcore\src\EFCore.InMemory\Query\Internal\InMemoryQueryExpression.Helper.cs:line 28
at Microsoft.EntityFrameworkCore.InMemory.Query.Internal.InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable`1.Enumerator.MoveNextHelper() in C:\dotnet\efcore\src\EFCore.InMemory\Query\Internal\InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs:line 153
at Microsoft.EntityFrameworkCore.InMemory.Query.Internal.InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable`1.Enumerator.MoveNext() in C:\dotnet\efcore\src\EFCore.InMemory\Query\Internal\InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs:line 107
at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Boolean& found)
at lambda_method139(Closure , QueryContext )
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) in C:\dotnet\efcore\src\EFCore\Query\Internal\QueryCompiler.cs:line 97
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression) in C:\dotnet\efcore\src\EFCore\Query\Internal\EntityQueryProvider.cs:line 78
at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
at Microsoft.EntityFrameworkCore.KeysWithConvertersTestBase`1.Can_query_and_update_owned_entity_with_int_bare_class_key() in C:\dotnet\efcore\test\EFCore.Specification.Tests\KeysWithConvertersTestBase.cs:line 2223
at Microsoft.EntityFrameworkCore.KeysWithConvertersInMemoryTest.Can_query_and_update_owned_entity_with_int_bare_class_key() in C:\dotnet\efcore\test\EFCore.InMemory.FunctionalTests\KeysWithConvertersInMemoryTest.cs:line 50 Types used: protected class OwnerBareIntClassKey
{
public OwnerBareIntClassKey(BareIntClassKey id)
{
Id = id;
}
public OwnerBareIntClassKey(BareIntClassKey id, OwnedBareIntClassKey owned)
{
Id = id;
Owned = owned;
}
public BareIntClassKey Id { get; set; }
public OwnedBareIntClassKey Owned { get; set; }
}
protected class OwnedBareIntClassKey
{
public OwnedBareIntClassKey(int position)
{
Position = position;
}
public int Position { get; set; }
}
protected class BareIntClassKey
{
public static ValueConverter<BareIntClassKey, int> Converter
= new(v => v.Id, v => new BareIntClassKey(v));
public static ValueComparer<BareIntClassKey> Comparer
= new ValueComparer<BareIntClassKey>(
(l, r) => l.Id == r.Id,
v => v.Id.GetHashCode(),
v => new(v.Id));
public BareIntClassKey(int id)
{
Id = id;
}
public int Id { get; set; }
} |
We recommend against using the in-memory provider for testing--see Testing EF Core Applications. While we have no plans to remove the in-memory provider, we will not be adding any new features to this provider because we believe valuable development time is better spent in other areas. When feasible, we plan to still fix regressions in existing behavior. |
See skipped tests in KeysWithConvertersInMemoryTest
The text was updated successfully, but these errors were encountered: