Nothing occurs while attempting to add a view to the edmx file.
I used the wxl editor to open the edmx file and found the following error:
warning 6013: The table/view 'CellularOrders.dbo.V_LINK' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it.
Important note: The view is just used for selecting data; I did not and do not need to add the table it is based on to the edmx.
As a result, I made a change to the T LINK table in the database and made one of the values that appears in the view the primary key. Then, when I tried adding the view to the edmx again, nothing happened once again.
What can I do to fix this? Exists a way to resolve this without putting anything on the table? Can I create a new view with fixed attributes that somehow wraps the previous view?
Each table or view that is added to the entity model requires a key. Actually, the main key isn't necessary. If the primary key for the table is not specified, Entity Framework will attempt to infer one following a simple rule: It will designate any non-nullable, non-computed, non-binary columns as entity keys. The entity cannot be automatically inserted if there is no such column, and the designer will provide the previously indicated warning. Workarounds include manually adding the view and choosing the key; however, once you've done that, you can't go back and utilize A database update since it will always erase your modifications.
If your specified key isn't unique, you can run into further issues with the internal usage of persona map.
Just add a column to your view, like the Row Number I did to generate this key.
SELECT ISNULL(CAST((row_number() OVER (ORDER BY tab.ENTRYDATE)) AS int), 0) AS EDMXID,...other columns go on
The entrydate is merely a column required for the built-in sql-server function row number, and the tab expression is a table alias.
You may choose many options, such as
select newid() as MYEDMXID,....so on