BlueshiftSoftware / EntityFrameworkCore

NoSQL providers for EntityFramework Core
Other
281 stars 57 forks source link

DbSet.Find throws InvalidOperationException #31

Closed IvanZheng closed 5 years ago

IvanZheng commented 5 years ago

Hi @crhairr , zooDbContext.Employees .Find(ObjectId.GenerateNewId()) will throw exception "System.InvalidOperationException : The operands for operator 'Equal' do not match the parameters of method 'op_Equality'". Please help to investigate it. It also blocks my project.

crhairr commented 5 years ago

.Find() is a convenience method baked into EF Core that makes a lot of bad assumptions. I have no control over how it works, including the fact that it assumes certain Equality aspects of the generic type parameter (without actually making those assumptions into type constraints).

Use an appropriate .Where() clause on the DbSet to filter on the key, since that's all that .Find really attempts to build for you anyway.

IvanZheng commented 5 years ago

Got it. I can adapt it myself.