Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:54:38+00:00 2026-06-17T10:54:38+00:00

Why exactly do we need to use the virtual keyword when declaring a navigation

  • 0

Why exactly do we need to use the “virtual” keyword when declaring a navigation property? I understand that the Code First framework uses it somehow to recognize that the property is a navigation property, but I’d like to know how. Specifically, I’d like to know how it relates to the description given in the MSDN documentation for the “virtual” keyword: http://msdn.microsoft.com/en-us/library/9fkccyh4(v=vs.80).aspx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:54:40+00:00Added an answer on June 17, 2026 at 10:54 am

    On runtime, Entity Framework will generate for you what’s called proxy-entities. Those entities are objects of dynamically created types that derive from your entity types.

    This allows you to use your entities as a POCO, which is a simple object that is not related to Entity Framework in any way, as it doesn’t inherit from EntityObject.

    On runtime, the dynamically created entity type inherits from your POCO, and overrides all your virtual properties to add the Entity Framework stuff that allows lazy-loading in the properties getters.

    Lazy loading is a complex process that requires your code to know about how the data comes from the database. As you don’t want your domain classes to know about the database and the EF stuff, you abstract your entities from EF and add virtual properties, so EF can override your base POCO and add its DB-related stuff on runtime.

    Same for change tracking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that to iterate through a Map , I need to use the
I have found some code that I need to use for my application but
I'm having trouble finding exactly the syntax I need to use to set the
I'm unsure about when exactly I need to use the spread-dot operator. If I
So, I've realised that I need to use NSCoding to save my custom objects
I have some POCO objects that are set up for use with Entity Framework
I am building an application that will need to use a mapping service to
I'm starting to create an iPhone/Android app that will need to use Plone users
I wanted to understand on when exactly I need to declare a variable as
I'm confused on why exactly I need to use references for the return type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.