title: Entity Framework property hiding
body: <p>I'm working with Entity Framework 6.0.2 Code First with Sql Server.</p>
  
  <p>I have a base class called Entity and since we can't extend enums I need to redefine a property type for another class called Company, so I'm using the new keyword to hide the base property and redefine it.</p>
  
  <pre><code>public interface IEntity 
  {
      Guid Id { get; set; }
      State State { get; set; }
  }
  
  public abstract class Entity : IEntity
  {
     public Guid Id { get; set; }
     public State State { get; set; }
  }
  
  public enum State 
  {
     Inactive = 0,
     Active = 1
  }
  
  public class Company : Entity 
  {
     public new CompanyState State { get; set; }
     public string SomeOtherProp { get; set; }
  }
  
  public enum CompanyState 
  {
     Inactive = 0,
     Active = 1,
     Extra = 2
  }
  </code></pre>
  
  <p>The problem I get is when Entity Framework is trying to create the DbContext it crashes with this error: "The item with identity 'State' already exists in the metadata collection. Parameter name: item"</p>
  
  <p>I have a workaround: I could change the State propery in Entity class to int and cast the appropriate enum to int, but I think I'll lose type safety / restriction that the enums have.</p>
  
  <p>I'd like to change the metadata info to avoid this error but I don't know how.</p>