Often we need to import to the Entity Framework an SQL View… and many times
the SQL View could be the result of UNION commands, GROUP, etc.
Entity Framework needs on every object a primary key (or similar) to use it.
So you can use the following rules :
To force entity framework to use a column as a primary key, use ISNULL.
To force entity framework not to use a column as a primary key, use NULLIF.
An easy way to apply this is to wrap the select statement of your view in another select.
FROM ( … ) AS temp