This topic is here several times but no answer give me option how to avoid this issue in EF.
My warning:
Warning Error 6002: The table/view 'ADContainersWithEnvironmentsView' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
Basicly I'm using database first approach with EF in my project.
I have view:
CREATE VIEW [dbo].ADContainersWithEnvironmentsView
AS
WITH ADContainerWithEnvironments(Id, LinkedEnvironmentId)
AS
(
SELECT adc.Id, adc.LinkedEnvironmentId
FROM ADContainer AS adc
WHERE ParentAdContainerId IS NULL
UNION ALL
SELECT subAdc.Id, parentAdc.LinkedEnvironmentId
FROM ADContainer AS subAdc
INNER JOIN ADContainerWithEnvironments parentAdc
ON subAdc.ParentAdContainerId = parentAdc.ID
)
SELECT ISNULL(Id,-1) AS Id, LinkedEnvironmentId FROM ADContainerWithEnvironments
As was explaind in other topics I NEED TO specify PK in my view with ISNULL(Id,-1) AS Id
I also mark in Diagram my Id as Entity Key check my screenshot
This warning I have for all my 10 views. After my changes I close my visual studio, even restart pc, or try it on other pc :) but warning is still there.
Thanks for help.