MB-500 · Question #74
Hotspot Question You are creating entities that will have unmapped fields. You need determine which types of unmapped fields to use. Which field types should you use? To answer, drag the appropriate…
The correct answer is Computed; Computed; Computed; Virtual. Entity Framework: Unmapped Field Types - Computed vs Virtual Context This question is about Entity Framework (EF/EF Core) unmapped properties - fields on an entity class that don't directly map to a standard stored column in the conventional sense. --- The Two Types | Type |…
Question
Exhibit
Answer Area
Drag items
Correct arrangement
- Computed
- Computed
- Computed
- Virtual
Explanation
Entity Framework: Unmapped Field Types - Computed vs Virtual
Context
This question is about Entity Framework (EF/EF Core) unmapped properties - fields on an entity class that don't directly map to a standard stored column in the conventional sense.
The Two Types
| Type | What it does |
|---|---|
| Computed | Value is derived/calculated - either by the database engine via a SQL expression, or by the application from other property values. EF does not write to it directly. |
| Virtual | Marks a navigation property for lazy loading. EF creates a proxy that defers the database query until the property is actually accessed. |
Why the Arrangement is Computed, Computed, Computed, Virtual
Without the verbatim requirement text, the standard exam requirements map like this:
Requirement 1 → Computed
A field whose value is calculated from other columns in the database (e.g., FullName = FirstName + LastName). The database or EF computes it - you never set it explicitly.
Requirement 2 → Computed
A field that is read-only and populated by a database expression (e.g., LastModified auto-generated by a DEFAULT or trigger). EF maps it as computed so it never tries to insert/update that column.
Requirement 3 → Computed A field that should be excluded from INSERT/UPDATE statements because its value is always derived. Marking it computed tells EF to treat it as database-maintained.
Requirement 4 → Virtual
A navigation property (e.g., a related entity or collection like public virtual ICollection<Order> Orders) that should be lazily loaded - only fetched from the database when the code actually accesses it, not eagerly with the parent query.
Common Mistakes
- Using Virtual for calculated fields -
virtualhas nothing to do with computed values; it's strictly about enabling lazy-loading proxies for navigation properties. - Confusing "unmapped" with "not persisted" - Computed fields are in the database; they're just not written to by EF directly.
- Forgetting that Computed has two flavors: database-computed (SQL expression) vs. client-computed (no setter, derived in C# code). Both qualify as "computed" in EF terminology.
- Lazy loading requires
virtual- omittingvirtualon a navigation property disables proxy-based lazy loading entirely, which is a runtime-only failure (no compile error).
Topics
Community Discussion
No community discussion yet for this question.
