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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:09:32+00:00 2026-05-25T03:09:32+00:00

I have problem I cannot find a solution for: basically I would like how

  • 0

I have problem I cannot find a solution for: basically I would like how to turn off cascading update on a EF CodeFirst many to many association.

I have two classes List and Recipient.

public class List
{
    public string DisplayName { get; set; }
    public DateTime? LastSyncronized { get; set; }
    public virtual ICollection<Recipient> Recipients { get; set; }
}

public class Recipient
{
    public int Id { get; set; }
    public String Name { get; set; }

    public virtual  ICollection<List> Subscriptions { get; set; }
}

During some processing I need to add to the Recipients property of a List a number of Recipient that I take from an external source.

Then I do my processing and at the end I have to same the List to update the LastSyncronized property.
Unfortunately, when I save, the automatic tracking of EF also saves into the database all the Recipients I’ve taken from the external source.
How can I configure the DbContext not to persist the new objects to the Database?

I tried removing them all from the collection, but even that they are added to the database anyway. In this case, the join table is unchanged, but the recipient one is added with the new recipients.

Thank you
Simone

  • 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-25T03:09:33+00:00Added an answer on May 25, 2026 at 3:09 am

    Not sure this is the right solution to this, but I set, in the DbContext class:

    Configuration.AutoDetectChangesEnabled = false;
    

    Now object added are not added to the database.

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

Sidebar

Related Questions

I have one obviously simple problem, but cannot find good solution, so I would
I have a very simple problem but cannot find a nice solution. I have
I have a simple problem that I cannot seem to find a solution to.
I have encountered a problem i cannot find a solution. I am using a
I have searched a long time and cannot find a solution to my problem.
I have tried using firebug to locate the problem, but cannot find the solution
I have a problem in Python, for which I cannot find any clean solution
I have been reading many posts that describe my problem but I cannot find
It is known that the halting problem cannot have a definite solution, one that
I've searched the site and I cannot find a solution for my problem, so

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.