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

  • Home
  • SEARCH
  • 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 7565415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:08:59+00:00 2026-05-30T14:08:59+00:00

As part of some tests of Entity Framework Code First I’m testing the change

  • 0

As part of some tests of Entity Framework Code First I’m testing the change tracking. In a small test database I have two cars in a table that I run a test method against:

Debug.WriteLine("Reading cars...");
var cars = context.Cars.ToArray();
Debug.WriteLine("Updating top speed of first car...");
Debug.WriteLine(string.Format("Type of car[0] is {0}", cars[0].GetType().ToString()));
cars[0].TopSpeed = 260;

Debug.WriteLine("Saving changes...");
context.SaveChanges();

I’ve added trace output to the getters and setters of the TopSpeed and Brand properties of the Car class to see how they are accessed. TopSpeed is an int? and Brand is a navigation property to the Brand entity. Running the above code gives the output below.

Reading cars...
Setting TopSpeed to 210 for ABC123.
Car: Getting TopSpeed for ABC123.
Setting TopSpeed to 250 for XYZ987.
Car: Getting TopSpeed for XYZ987.
Updating top speed of the first car...
Type of car[0] is System.Data.Entity.DynamicProxies.Car_18E3E11297DC48759312BDF1C2FFEBE9F19BAE5D487CED2A9781A6CA730071EA
Setting TopSpeed to 260 for ABC123.
Saving changes...
Car: Getting Brand for ABC123.
Car: Getting Brand for XYZ987.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for XYZ987.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.
Car: Getting TopSpeed for ABC123.

The type of the object is an EF dynamic proxy for change tracking. Still, when calling SaveChanges() the properties of the unchanged XYZ987 car are read. I thought that change tracking would cause EF to only read the objects that were known to change, or am I missing something? Is there something else I need to add to enable change tracking?

  • 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-05-30T14:09:00+00:00Added an answer on May 30, 2026 at 2:09 pm

    Even though all requirements for a change tracking proxy was fulfilled, EF still uses the automatic change tracking unless explicitly turned off:

    context.Configuration.AutoDetectChangesEnabled = false;
    

    The documentation on AutoDetectChangesEnabled is confusing:

    True if the automatic detection of changes in the configuration is
    enabled; otherwise, false.

    Looking at the ADO.NET’s blog they explain it correctly.

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

Sidebar

Related Questions

I have some .csv files which I'm using as part of a test bench.
I'm trying to write some small tests for a fairly small part of a
I have some integration tests that test the processing of USB data from a
I would like to update (change the content) some part of the webpage without
How can I change a color of some part of treenode Text ? For
I have an executable that I need to run some tests on in C++
As part of some build automation of running xUnit.net tests with MSBuild , I'm
I was writing some Unit tests last week for a piece of code that
I'm doing some user tests of my new iOS app and store some test
I use H2 Database for my unit tests. In my application, I have an

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.