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:
- make sure not expose
dbset<haircutstyle>
indbcontext
-derived class - make sure not have mention of
haircutstyle
inonmodelcreating
override - mark
haircutstyle
property usingnotmapped
attribute.
Comments
Post a Comment