Trying to add a view that combines data from two tables with a right join. The primary table has a primary key and I’ve included that in the view. When I add a model to my project, the view isn’t added and I get the warning:
The table/view ‘[TABLE NAME]‘ does not have a primary key defined ad no valid primary key could be inferred. This table/view has been excluded.
I need to model to be updated by non-developers so don’t want to start doing workarounds in the edmx file that could be overwritten by the designer.
So far I’ve tried:
Adding the view.
Adding the PK column of the primary table to the view and trying again.
Adding the underlying tables into the model.
Always the same result. If it helps, the data provided by the service will be read-only.
You should be able to add a view, as long as there is a primary key in the underlying table or there are viable columns (non-nullable, non-binary) in the view. If not, you would have to add code manually that would be lost during a refresh.
You mention a right join. Are you certain that there is a primary key in the table on the right of the join. ie. the table whose data is always returned, rather than the table that can return all nulls?