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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:13:04+00:00 2026-05-28T20:13:04+00:00

I have been using a lot Entity Framework in a MVVM WPF application recently

  • 0

I have been using a lot Entity Framework in a MVVM WPF application recently and I ran into some issues. To display data, my view-models are using a short-live ObjectContext. These view-models will be used in a long running process, therefore I prefered using short-live ObjectContext to not deteriorate performance.

So basically it means that my entities are consumed in disconnected mode. These entites can be created, viewed, updated and deleted. I had no problem for saving changes back to database using disconnected mode. But I found a particular case where changes are not saved with no error showing up on call of SaveChanges() method. This happens when I try to update an entity that has a collection property. Scalar property of the entity are persisted without problem but changes on collections are not reflected to database, like if if it was not able to track these changes on reconnection.

Here is a sample code of my case where I change the entity name and then add an object to its report collection. After SaveChanges(), only the client name has been reflected on database.

this.Client.Name = "Test Client";
this.Client.Reports.Add(new Report { Name = "Test Report" });

using (ReportCompositionEntities entities = new ReportCompositionEntities(this.connectionStringName))
{
    entities.Clients.ApplyCurrentValues(this.Client);
    entities.SaveChanges();
}

So am I doing doing something wrong or EF is simply not able to track this kind of changes when reattaching an entity?

  • 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-28T20:13:05+00:00Added an answer on May 28, 2026 at 8:13 pm

    That is exactly what happens. There is no change tracking and EF doesn’t know about changes performed in navigation property. Also ApplyCurrentValues is able to process only scalar and complex properties. Not navigation properties.

    When modifying relations in detached scenarios you must manually tell EF what relations where modified once you attach the entity. You can create some custom logic providing these information and use ObjectStateManager to configure states of all relations or you can simply load the current version with relations from database and manually synchronize changes from detached version to loaded attached version.

    Btw. I never used MVVM so I’m not sure how it applies in this case but in case of MVP you can use long living context if it is used for single operation – for example edit view will be handled by its own presenter with its own context. This context will live as long as view will be used to edit single entity / aggregate = it will be used to load entity and the same context will be used to save entity because in this case the edit is performed by same execution context and belongs to single unit of work.

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

Sidebar

Related Questions

I have been experimenting recently with Silverlight, RIA Services, and Entity Framework using .NET
I have been looking into using the Entity Framework in my C# game server
I've been using extension methods quite a bit recently and have found a lot
Recently I have been using thrust a lot. I have noticed that in order
I have been playing with Entity Framework and so far I like using it
I have been using linq in combination with entity framework for a few months
I know there have been a lot of questions about Entity Framework doing cross
I have been using WinForms since the first framework introduced and invested a lot
I have been using Selenium a lot lately (testing an ExtJs app) and while
I have been using a lot of position:relative; in my design, I just find

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.