It is true that the Entity Framework does not like SQL Server views because the primary key is not obvious in the view. Unfortunately, specifying [Key] in the model does not seem sufficient. However, this can be done and is very useful in 98% of cases when there is a view that joins tables, and you just want to display it in a grid. The key (pardon the pun) is to correctly define the performance.
My initial view contained the following columns:
DepartmentCode(varchar(8),not null) DepartmentName(varchar(60), not null) DivisionCode(varchar(8), null) DivisionName(varchar(8), null) StatusCode(char(1), not null) Virtual(varchar(1), not null)
and in my model I indicated
[Key] [Column("DepartmentCode")] [DatabaseGenerated(DatabaseGeneratedOption.None)] [StringLength(8)] [Display(Name = "Department Code")] public string DepartmentCode { get; set; }
When I close this and display the Index view, I received an error message with a primary key. Apparently, the Entity Framework assumes that all non-empty fields contribute to the primary key.
Removing extra null values did the trick. I made the columns in the view be NULL using the following:
CREATE view [dbo].[Departments] as select DepartmentCode ,nullif(DepartmentName,'') as DepartmentName ,nullif(DivisionCode,'') as DivisionCode ,nullif(DivisionName,'') as DivisionName ,nullif(StatusCode,'') as StatusCode ,nullif(Virtual,'') as Virtual from ....
Presentation columns now look like this
DepartmentCode(varchar(8),not null) DepartmentName(varchar(60), null) DivisionCode(varchar(8), null) DivisionName(varchar(8), null) StatusCode(char(1), null) Virtual(varchar(1), null)
As soon as I changed the view, the index view worked correctly.
I also confirmed that the view containing the composite (multi-column) key will also work as long as only these columns are not zero, and in your model you specify [Key] for each column, and also add Order = 1 and Order = 2 in Column annotations on these key columns.
Of course, the assumption is that you have permission to change the view (or you can create an alternative view). I can only confirm this on MVC 5 and Entity Framework 6.