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 8551731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:15:35+00:00 2026-06-11T14:15:35+00:00

I have updated a project to use the new Entity Framework shipped with VS2012

  • 0

I have updated a project to use the new Entity Framework shipped with VS2012. However, I ran into some issues ’cause of which my code is throwing exceptions.

In the VS2010 version of Entity Framework, I was able to create or modify an Entity and use its navigation properties before calling SaveChanges()

For example:
A Navigation property of a client having a collection of Invoices.

Client c = new Client();
Invoice I = new Invoice();
c.Invoices.Add(I);

I would then be able to use Invoice.Client somewhere in my code before actually saving it without issue. Now Invoice.Client == null.

Similarly in setting I.Client = C, I does not show up under C.Invoices

What am I missing here or is this just simply how Entity Framework 5 is?

EDIT

In VS2010, I Created a new project, added the same DataSource and the following code worked as expected:

Client C = new Client();
C.Name = "Test";
Invoice I = new Invoice();
C.Invoices.Add(I);
MessageBox.Show(I.Client.Name);

Did the exact same thing in VS2012 and no dice.

  • 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-11T14:15:36+00:00Added an answer on June 11, 2026 at 2:15 pm

    In your above example you aren’t actually attached to the context.

    Back-references for EF are only populated via a process called fixups which runs as a result of DetectChanges which in turn is triggered by (in your case) IDbSet<>.Add()

    If you modify your code to attach Client to the context before adding an invoice to it you should see the expected behaviour

    EDIT:

    I haven’t really used this feature with DB First (.edmx) but you can enable it by using the below model type in 2010.

    This model type has been removed in 2012 as STEs have been deprecated. (Although my understanding is that they still work for backward compatibility so if you were to upgrade a project from 2010-2012 you would still be able to use that model)

    Self Tracking Entities

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

Sidebar

Related Questions

I have started to look at the Entity Framework for a project I am
I'm new to infragistics. I have a database and a datalayer with entity framework
I'm utilizing Entity Framework 4.3 Migrations in my project. I would like to use
I have an Entity Framework v1 project. I have two entities (Roles and Permissions),
I'm trying to use LINQPad with my MVC3 project that is using Entity Framework
I have a question. Now in project we use git for automatically update testing
I have a database that was created with the Entity Framework's code first approach.
Basically there is a project I am new to that uses maven. I have
I have a complex web project template where files can be divided into three
I have seen many examples using Entity Framework in MVC3 applications, they are very

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.