title: Import Select SQL query stored procedure using Entity Framework 4 in Asp.Net and C# Visual Studio 2010
body: <p>I am trying to import a stored procedure using Entity Framework 4 in an Asp.Net MVC project using C#. But when I try to update the model into entity diagram (*.edmx), it will be updated into the Entity name.Store inside stored procedure folder.</p>
  
  <p>Stored procedure:</p>
  
  <pre><code>CREATE PROCEDURE Sp_Feedback
  AS
  BEGIN
      SELECT 
          f.User_Id, f.Over_All_Rating, f.Features_Liked,
          f.Features_Need_Improvement,
          f.Will_Recommend_Us, f.Customer_Service_Rating, f.Comments 
      FROM 
          Feedback f
  END
  </code></pre>
  
  <p>In my stored procedure I have selected a few columns from the table (not all columns). So I need to add a new entity for model mapping to the table. Once entity is created and add scalar properties to the entity to specify exact name in the table which I need to retrieve through the stored procedure. At last I had to mapping the new entity property name to the exact table entity.</p>
  
  <p>When you expand the expand the stored-procedure folder there is a imported stored procedure right click stored procedure select <strong>Add Function Import</strong> option and dialog open displays that "<strong>Function Import Name</strong>" and "<strong>Stored Procedure Name</strong>" is already detected from the stored procedure and there is another option which is "<strong>Returns a Collection Of</strong>"</p>
  
  <p>It contains four option which are</p>
  
  <ol>
  <li>None</li>
  <li>Scalars</li>
  <li>Complex</li>
  <li>Entities</li>
  </ol>
  
  <p>In the <strong>Returns a Collection</strong> option I had to select the entities option to select the newly created entities for the mapping the stored procedure retrieved columns, because I need to get the list of records from the table.</p>
  
  <p>Once I finished build the project, I got an error which is there is "no key value" for the newly created entity while mapping to the table entity.</p>
  
  <p>After that I added a scalar property name for key value to the newly entity to map to the table entity. Again I build the project I got another error which is both the entities have the same key value.</p>
  
  <p>I need to import the Select query based stored procedure using Entity Framework 4.</p>