Can't Add A View to EF Data Model

If your view does not contain the primary key column,then it wont add to edmx file.


I have experienced this same behaviour when I try to add a view that doesn't select a primary key from another table. (Like Ladislav Mrnka has commented)

My strategy for solving this is to reduce the view to as simple as possible (1 column) and try and to get it added. Once you have it added to the model, slowly bring in more columns and refresh the model to make sure the view is still there. You can usually identify what section of the view is giving EDM problems.


Same issue here, what I did was to add the PrimaryKey on the View, using :

..... (SELECT      TOP (100) PERCENT ROW_NUMBER() OVER (ORDER BY R.Road DESC) AS RoadNumber......

And then I had to do a CAST of this :

ISNULL (CAST(RoadNumber AS INT),0)AS RoadNumber

The column must be (not null), that's why the CAST at the end.