title: Entity Framework 7 Stored Procedure Result to Model
body: <p>I have a Model which is mapped to the database via EF7. All properties are identical to the mapped columns of the table.</p>
  
  <p>Now I have a Stored Procedure, which returns some Joined Columns but the basis is still the mapped Model.</p>
  
  <p>Here is my model(Entity) which is mapped to Table1 on my database.</p>
  
  <p><code>public partial class Table1
      {
          public int id { get; set; }
          public bool Column1{ get; set; }
          public int Column2 { get; set; }
          public int Column3 { get; set; }
          public int Column4 { get; set; }
          public int Column5 { get; set; }
  }</code></p>
  
  <p>My StoredProcedure returns all of these columns and additionally a Column from another table, which contains additional information on this object.</p>
  
  <p>So My StoredProcedure looks like this:</p>
  
  <pre><code>CREATE PROCEDURE Table1_Select
      AS
          BEGIN
              SELECT  Column1,
                      Column2,
                      Column3,
                      Column4,
                      Column5,
                      Table2.JoinedColumn1
              FROM    Table1
              JOIN    Table2 on Table1.ID = Table2.ID_Table1
          END
  </code></pre>
  
  <p>My Idea was to just add a Property to the Model </p>
  
  <pre><code>public string JoinedColumn1 {get; set;}
  </code></pre>
  
  <p>This is working for executing the StoredProcedure, but it's not working as soon as I want to get one Entity with </p>
  
  <pre><code>MyContext.Table1.FirstOrDefault(t=&gt;t.id == 1)
  </code></pre>
  
  <p>this always returns a Server Error 500 in Fiddler whereas the Stored Procedure Execution with "Table1.FromSql("Table1Select")" works fine.</p>
  
  <p>Or do I have to decide whether to use StoredProcedures for my Model OR accessing Entities directly?</p>
  
  <p>Any Best-Practices or solutions for this? </p>
  
  <p>Many thanks in advance.
  Nicn</p>