title: Calculated column in EF Code First
body: <p>I need to have one column in my database calculated by database as (sum of rows) - (sum of rowsb). I'm using code-first model to create my database.</p>
  
  <p>Here is what I mean:</p>
  
  <pre><code>public class Income {
        [Key]
        public int UserID { get; set; }
        public double inSum { get; set; }
  }
  
  public class Outcome {
        [Key]
        public int UserID { get; set; }
        public double outSum { get; set; }
  }
  
  public class FirstTable {
        [Key]
        public int UserID { get; set; }
        public double Sum { get; set; } 
        // This needs to be calculated by DB as 
        // ( Select sum(inSum) FROM Income WHERE UserID = this.UserID) 
        // - (Select sum(outSum) FROM Outcome WHERE UserID = this.UserID)
  }
  </code></pre>
  
  <p>How can I achieve this in EF CodeFirst?</p>