This is again EF's weakness in supporting LINQ. The good old LINQ to SQL correctly translated it depending on the runtime value of val.
I suggest you go with this:
var objs = db.Objects.Where( o => (o.Field1 == val) || (o.Field1 == null && val == null));
If EF translates this explicitly, the SQL Server query optimizer will actually pick up this template and optimize it before checking for "equals-with-nulls". You can even search for indexes using this code template, it just works. In query plans, this is displayed as IS as opposed to EQ .
source share