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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:14:23+00:00 2026-05-30T09:14:23+00:00

I am using silverlight mvvm light framework. when I was trying to delete entity

  • 0

I am using silverlight mvvm light framework. when I was trying to delete entity I got The specified entity is not contained in this EntitySet. error but in my Database that entity is already there.

   context.FormSection.Remove(formSection);

In this code I am getting error.

This is my code where I am doing delete operation

   public void DeleteSectionQuestion(Form currentForm,CustomSectionTree selectedSectionQuestion, DeleteDelegate callback)
    {
        FormSection fs = new FormSection();

        foreach (Question q in selectedSectionQuestion.Questions)
        {
            fs.FormID = currentForm.FormID;
            fs.SectionID = selectedSectionQuestion.SectionID;
            fs.QuestionID = q.QuestionID;
            context.FormSections.Remove(fs);
        }

        SubmitOperation so = context.SubmitChanges();
        so.Completed += (s, args) =>
        {
            if (so.HasError)
            {
                so.MarkErrorAsHandled();
                callback.Invoke(false, so.Error);
            }
            else
                callback.Invoke(true, null);
        };
    }
  • 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-30T09:14:25+00:00Added an answer on May 30, 2026 at 9:14 am

    Look at the following piece of your code:

    FormSection fs = new FormSection();
    
    foreach (Question q in selectedSectionQuestion.Questions)
    {
        fs.FormID = currentForm.FormID;
        fs.SectionID = selectedSectionQuestion.SectionID;
        fs.QuestionID = q.QuestionID;
        context.FormSections.Remove(fs);
    }
    

    You are creating a new instance of FormSection, and then try to delete it multiple times. Entities/EntitySet don’t work that way: the context tracks which entities you retrieved from the database. It means that if you try to remove an entity that is not an instance of an entity that came from the database, it is unknown for the context.

    You should have a list of queried FormSections in your viewmodel, you should delete instances of FormSection that come from this list so they are known by the context.

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

Sidebar

Related Questions

I am creating a Silverlight 4 application with Entity Framework, RIA Services and MVVM-Light
I've got this Silverlight Prism application that is using MVVM. The model calls a
First time poster. I'm using MVVM-Light with Silverlight 4 and RIA Services. This has
I'm trying to follow this MVVM Light Toolkit V3 Alpha 2: EventToCommand behavior tutorial.
I'm using mvvm light to build a Silverlight application. Is there a code snippet
I'm trying to build a sample game in Silverlight 4 using the MVVM design
I'm trying to set seletected value to a pre-loaded combobox using silverlight with MVVM.
I am using SL4, MVVM Toolkit, Entity Framework 4 & WCF RIA Services. I
I am using RIA services to serve entities to a MVVM-Light enabled Silverlight application.
Using Silverlight 4 / MVVM. I am trying to bind a ViewModel to a

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.