title: Entity Framework 4 (using EDMX), how to add a field into to model that DB does not have the field actually
body: <p>I need to add a field into model that Database does not have the field actually.</p>
  
  <p>Because, firstly I tried to add the field into Entity class only.</p>
  
  <pre><code>public partial class Weborder
  {
    (Auto Generated)
    public int orderno {get; set;}
    .
    .
    .
    (Add Manually)
    public string newField1 {get; set;} //this is new field that DB does not have
    public string newField2 {get; set;} //this is new field that DB does not have
  }
  </code></pre>
  
  <p>and later, when I update EDXM then EDMX remove the new fields because the database does not have the field. :(</p>
  
  <p>So I add the field into EDMX model manually. (Add -> Scalar Property)</p>
  
  <p>then an error occur while compiling, the error message say : </p>
  
  <pre><code>Error   1   Error 3004: Problem in mapping fragments starting at line 399:No mapping specified for properties ...
  An Entity with Key (PK) will not round-trip when:...
  </code></pre>
  
  <p>Anybody know how to add new fields into entity class ?</p>
  
  <p>Thank you!</p>
  
  <p><strong>EDITED FOR : 
  If your model is a representation of your database and in the database you don't have the field, why do you want to add it manually?</strong> </p>
  
  <p>=></p>
  
  <p>When retrieve data, the return type of object is the entity class.</p>
  
  <p>and before passing data from controller to view, I need to add more data(fields) into the IQueryable result.</p>
  
  <p>ex)</p>
  
  <pre><code>public DbSet&lt;WEBORDERLN&gt; WEBORDERLNs { get; set; }
  
  //repository
  public IQueryable&lt;WEBORDERLN&gt; WebOrderLns
  {
        get { return context.WEBORDERLNs; }
  }
  </code></pre>
  
  <p>and now I get the weborderln data in controller. and before passing view, I need to </p>
  
  <p>add extra data into the result.</p>
  
  <pre><code>var data = webOrderLnRepository.WebOrderLns.Where(e =&gt; e.PICKNO == OrderNo).ToList();
  
  foreach (WEBORDERLN weborderln in data)
  {
     weborderln.[NEW FIELD] = "EXTRA DATA";   //// FOR THIS, I NEED TO ADD NEW FILED INTO ENTITY CLASS
  }
  
  //return data
  </code></pre>
  
  <p>I hope it could explain the question :)</p>
  
  <p>Thanks again.</p>