c# - Entity Framework code first: How to ignore classes -


this similar questions here , here, old , have no answers.

let's have following classes:

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; } } 

let's haircutstyle data stored in table in database (i paul mitchell himself). want use haircutstyle class poco class - use in code represent hair cut styles, don't need read/write information in database. (assume have separate service layer can populate data these classes other database.)

how can tell ef not create haircutstyle table in current db context? @ same time, want store value in customerhaircutpreference table reference haircutstyle data stored elsewhere. "virtual" foreign key of sorts, isn't constrained actual database fk constraint.

there 3 things ensure:

  1. make sure not expose dbset<haircutstyle> in dbcontext-derived class
  2. make sure not have mention of haircutstyle in onmodelcreating override
  3. mark haircutstyle property using notmapped attribute.

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -