Note that there are some explanatory texts on larger screens.

plurals
  1. POAn object with the same key already exists in the ObjectStateManager
    primarykey
    data
    text
    <p>Anybody can help me with this code I am getting this error message:</p> <blockquote> <p>Server Error in '/' Application. An object with the same key already exists in the ObjectStateManager. The existing object is in the Modified state. An object can only be added to the ObjectStateManager again if it is in the added state. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p> <p>Exception Details: System.InvalidOperationException: An object with the same key already exists in the ObjectStateManager. The existing object is in the Modified state. An object can only be added to the ObjectStateManager again if it is in the added state.</p> </blockquote> <p>Source Error:</p> <pre><code>Line 90: public void AddToTwitter(Twitter twitter) Line 91: { Line 92: base.AddObject("Twitter", twitter); Line 93: } </code></pre> <p>Source File: C:\Users\dell\Documents\Visual Studio 2010\Projects\MvcApplication3\MvcApplication3\Models\TwitterEntity.Designer.cs Line: 92 </p> <p>the code is :</p> <pre><code>Models.TwitterEntities entity = new Models.TwitterEntities(); Models.Twitter tw = new Models.Twitter(); foreach (Hashtable item in (ArrayList)hs["results"]) { foreach (DictionaryEntry subitem in item) { if (subitem.Key.ToString() == "from_user") { tw.from_user = (string)subitem.Value; Response.Write("&lt;br&gt;" + (string)subitem.Value); entity.AddToTwitter(tw); } if (subitem.Key.ToString() == "to_user") { tw.to_user = (string)subitem.Value; Response.Write("&lt;br&gt;" + (string)subitem.Value); entity.AddToTwitter(tw); } entity.SaveChanges(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload