Comparison of user class objects is not supported in Linq to entities
The linq expression is:
var query = from p in _db.LogProjects
where p.Well == well
select p;
( Well is a user class )
An exception will be thrown:
Unable to create a constant value of type 'Closure type'. Only primitive types (for instance Int32, String and Guid) are supported in this context.
So, you can change the linq expression to:
var query = from p in _db.LogProjects
where p.Well.WellID == well.WellID
select p;
reference:
ADO.NET Entity Framework Comparison Frustration
Entity Framework Comparison Frustration: Explained