title: MVC3 - Adding a stored proc to the Model
body: <p>I create the stored proc:</p>
  
  <pre><code>CREATE PROCEDURE  dbo.GetCampaigns  
      @UserID varchar(15) 
  AS
  
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
  
      SELECT CampaignId, CampaignName,  Expiry, LaunchDate FROM feeds.dbo.Campaigns  WHERE userid=@UserID;
  
  END
  </code></pre>
  
  <p>The campaignId in the return is a unique key.</p>
  
  <p>I drag and drop this into serverExplorer. I build it and it creates the Model. I right click on controller to create the controller, data context etc. It pops up a box with the message:</p>
  
  <pre>
  Unable to retrieve metadaat for xxx.Models.CampaignResult. One or more validation errors were detected during model generation:
  -System Data.Edm.EdmEntitytype: Entity Type getCampaingsResult has no key defined. Define a key for this entity type
  -System.Data.Edm.EdmEntitySet: EntityType: EntitySet GetCampaignResults is based on type GetCampaignResult that has no keys defined.
  </pre>
  
  <p>I'm confused. Thanks in advance. Any help appreciated.</p>