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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:53:00+00:00 2026-05-22T22:53:00+00:00

for example i’ve got a TestItem entity: public class TestItem { [Key] public int

  • 0

for example i’ve got a TestItem entity:

public class TestItem
{
    [Key]
    public int Id { get; set; }
    public string Description { get; set; }
}

and view model with list, method where we’ll add new items to this list, and method where we’ll call _TestDomainContext.SubmitChanges

EntityList<TestItem> SomeList = new EntityList<TestItem>(_TestDomainContext.TestItems);

private void AddTestItem()
{
    SomeList.Add(new TestItem());
}

private void SubmitChanges()
{
    _TestDomainContext.SubmitChanges();
}

And now, after the first item is added to list and SubmitChanges() is called everything works perfectly, but when i try to add second item i get the exception :
An entity with the same identity already exists in this EntitySet.

is the only way to get rid of this is manually refresh the SomeList in OnSubmitComplete callback i.e.:

_TestDomainContext.TestItems.Clear();
_TestDomainContext.Load(_TestDomainContext.GetTestItemsQuery());

Thank You !

  • 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-22T22:53:01+00:00Added an answer on May 22, 2026 at 10:53 pm

    Yes, you have to refresh your client copy of the cache so that the newly added Id fields are there.

    Just as a proof of concept try the below code:

    private void AddTestItem()
    {    
        var key = _TestDomainContext.TestItems.Max(c=> c.Id) + 1;
        SomeList.Add(new TestItem(){Id = key});
    }
    

    This will resolve the conflict but is not the right way of doing it, it is the best to refresh/load the query again after a submit.

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

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
Example int *ptr; *ptr = 1000; can I catch memory access violation exception using
Example in Unix module: val environment : unit -> string array Why not just:
Example html: <div class=red></div> <div class=green></div> <div class=blue></div> <div class=apple></div> I want to loop
example <reference>employee</reference> <data>123</data> how to parse using c# so that i should get employee
Example code: <div class=ex>Bla bla bla bla</div> In the top will be background-image and
Example: int main(void) { int x = 10, y; asm (movl %1, %%eax; movl
Example 1 /** *Program Name: Cis36L0411.java *Discussion: Class -- Data Members ONLY * Method
Example = #define a 100 #define b 200 main() { int c=a+b; } After
Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe

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.