title: How to create a MVC Model from SQL Server 2014 Functions
body: <p>I am using SQL Server 2014 and I have a function that takes start and finish date as parameters and returns a table. </p>
  
  <p>In SQL Server when I call my function I use;</p>
  
  <pre><code>SELECT * 
  FROM PV_GetLogByDT ('2015-11-01', '2016-03-04')
  </code></pre>
  
  <p>Now I want to use this function to create a MODEL for my MVC project. How can I do that?</p>
  
  <p>When I do I get this error:</p>
  
  <hr>
  
  <h2>Microsoft Visual Studio</h2>
  
  <p>Error</p>
  
  <p>There was an error running the selected code generator:</p>
  
  <p>'Unable to retrieve metadata for 'LTKB.CARD.Models.PV_GetCARDLogByDT_Result'. One or more validation errors were detected during model generation:</p>
  
  <p>CARDNOLIST: : EntityType 'CARDNOLIST' has no key defined. Define the key for this EntityType.
  CARDPASSLIST: : EntityType 'CARDPASSLIST' has no key defined. Define the key for this EntityType.
  CARDPINLIST: : EntityType 'CARDPINLIST' has no key defined. Define the key for this EntityType.
  RESULTLIST: : EntityType 'RESULTLIST' has no key defined. Define the key for this EntityType.
  CARDNOLIST: EntityType: EntitySet 'CARDNOLIST' is based on type 'CARDNOLIST' that has no keys defined.
  CARDPASSLIST: EntityType: EntitySet 'CARDPASSLIST' is based on type 'CARDPASSLIST' that has no keys defined.
  CARDPINLIST: EntityType: EntitySet 'CARDPINLIST' is based on type 'CARDPINLIST' that has no keys defined.
  RESULTLIST: EntityType: EntitySet 'RESULTLIST' is based on type 'RESULTLIST' that has no keys defined.</p>
  
  <hr>
  
  <h2>OK</h2>