title: Warning Error 6002: The table/view does not have a primary key defined
body: <p>This topic is here several times but no answer give me option how to avoid this issue in EF.</p>
  
  <p>My warning:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>Basicly I'm using database first approach with EF in my project.</p>
  
  <p>I have view:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>As was explaind in other topics I NEED TO specify PK in my view with <strong>ISNULL(Id,-1) AS Id</strong> </p>
  
  <p>I also mark in Diagram my <strong>Id as Entity Key</strong> check my screenshot
  <a href="https://i.stack.imgur.com/vz4cd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vz4cd.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>Thanks for help.</p>