title: Adding additional properties to an entity framework 4 code first CTP 5 entity
body: <p>I am using <code>ASP.NET MVC 3</code> and <code>Entity Framework code first CTP 5</code>.  I was wondering if it is possible to add additional properties that is not mapped to a table column?</p>
  
  <p>I haved a News class and it is defined as such:</p>
  
  <pre><code>public class News : Entity
  {
     public int NewsId { get; set; }
     public string Title { get; set; }
     public string Body { get; set; }
     public bool Active { get; set; }
  }
  </code></pre>
  
  <p>My database context class:</p>
  
  <pre><code>public class MyContext : DbContext
  {
     public DbSet&lt;News&gt; Newses { get; set; }
  }
  </code></pre>
  
  <p>In the entity class I have a property defined like:</p>
  
  <pre><code>public IList&lt;RuleViolation&gt; RuleViolations { get; set; }
  </code></pre>
  
  <p>I have not code this part yet, but I want all broken rules to be added to this list when the object is validated.  The error that I am getting is:</p>
  
  <pre><code>One or more validation errors were detected during model generation:
  
      System.Data.Edm.EdmEntityType: : EntityType 'RuleViolation' has no key defined. Define the key for this EntityType.
      System.Data.Edm.EdmEntitySet: EntityType: The EntitySet RuleViolations is based on type RuleViolation that has no keys defined.
  </code></pre>
  
  <p>Here is my reposity code:</p>
  
  <pre><code>public News FindById(int newsId)
  {
     return context.Database.SqlQuery&lt;News&gt;("News_FindById @NewsId",
        new SqlParameter("NewsId", newsId)).FirstOrDefault();
  }
  </code></pre>
  
  <p><strong>UPDATE 2011-03-02:</strong></p>
  
  <p>Here is my <code>Entity</code> class:</p>
  
  <pre><code>public class Entity
  {
     public IList&lt;RuleViolation&gt; RuleViolations { get; set; }
  
     public bool Validate()
     {
        // Still needs to be coded
        bool isValid = true;
  
        return isValid;
     }
  }
  </code></pre>
  
  <p>Here is my <code>RuleViolation</code> class:</p>
  
  <pre><code>public class RuleViolation
  {
     public RuleViolation(string parameterName, string errorMessage)
     {
        ParameterName = parameterName;
        ErrorMessage = errorMessage;
     }
  
     public string ParameterName { get; set; }
     public string ErrorMessage { get; set; }
  }
  </code></pre>
  
  <p>Here is my context class:</p>
  
  <pre><code>public class MyContext : DbContext
  {
     public DbSet&lt;News&gt; Newses { get; set; }
  
     protected override void OnModelCreating(ModelBuilder modelBuilder)
     {
        modelBuilder.Entity&lt;News&gt;().Ignore(n =&gt; n.RuleViolations);
     }
  }
  </code></pre>