title: Entity Framework code first: How to ignore classes
body: <p>This is similar to questions <a href="https://stackoverflow.com/questions/7886672/how-to-ignore-entity-in-entity-framework-code-first-via-setup">here</a> and <a href="https://stackoverflow.com/questions/27543396/entity-framework-code-first-ignore-complete-entity">here</a>, but those are old and have no good answers.</p>
  
  <p>Let's say I have the following classes:</p>
  
  <pre><code>class HairCutStyle { 
     public int ID { get; set; }
     public string Name { get; set; }
  }
  
  class CustomerHairCutPreference {
     public int ID { get; set; }
     public Customer Customer { get; set; }
     public HairCutStyle HairCutStyle { get; set; }
  }
  </code></pre>
  
  <p>Let's say my HairCutStyle data is stored in a table in another database (I get it from Paul Mitchell himself). I want to use the HairCutStyle class as a POCO class - something that I will use in code to represent hair cut styles, but I don't need to read/write that information in my database. (Assume I have a separate service layer that can populate the data for these classes from the other database.)</p>
  
  <p>How can I tell EF NOT to create a HairCutStyle table in my current db context? But at the same time, I want to store a value in the CustomerHairCutPreference table that is a reference to the HairCutStyle data stored elsewhere. A "virtual" foreign key of sorts, that isn't constrained by an actual database FK constraint. </p>