<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : An entity with this key already exists</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2012 : An entity with this key already exists</description>
  <pubDate>Fri, 10 Apr 2026 18:57:11 -700</pubDate>
  <lastBuildDate>Mon, 09 Dec 2013 15:35:45 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=4623</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>An entity with this key already exists : Hi,Thanks for the prompt reply.The...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4623&amp;PID=17299#17299</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1189" rel="nofollow">iDave</a><br /><strong>Subject:</strong> 4623<br /><strong>Posted:</strong> 09-Dec-2013 at 3:35pm<br /><br />Hi,<br><br>Thanks for the prompt reply.<br>The fifth parameter of the DataEntityProperty was indeed set to false.<br>Regenerating the code or updating the model didn't solve the problem until I deleted the model and created it again.<br><br>Thanks a lot for the help, I do really appreciate it!<br><br>Have a nice day!<br>]]>
   </description>
   <pubDate>Mon, 09 Dec 2013 15:35:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4623&amp;PID=17299#17299</guid>
  </item> 
  <item>
   <title>An entity with this key already exists : Check the DataEntityProperty DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4623&amp;PID=17297#17297</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 4623<br /><strong>Posted:</strong> 08-Dec-2013 at 1:29pm<br /><br />Check the DataEntityProperty DevForce generated for this.&nbsp; The fifth parameter, for "isAutoIncrementing", should be true.&nbsp; If not, either the generated code is out of sync with the database, or somehow incorrect.&nbsp; If you regenerate the code it should sync up with your database.]]>
   </description>
   <pubDate>Sun, 08 Dec 2013 13:29:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4623&amp;PID=17297#17297</guid>
  </item> 
  <item>
   <title>An entity with this key already exists : Good day,I&amp;#039;ve the following...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4623&amp;PID=17296#17296</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1189" rel="nofollow">iDave</a><br /><strong>Subject:</strong> 4623<br /><strong>Posted:</strong> 06-Dec-2013 at 7:17pm<br /><br />Good day,<br><br>I've the following code:<br><br><table width="99%"><tr><td><pre class="BBcode"><br>Role role;<br>foreach (var department in departments)<br>{<br>&nbsp;&nbsp;&nbsp; role = new Role();<br>&nbsp;&nbsp;&nbsp; role.Name = department;<br><br>&nbsp;&nbsp;&nbsp; em.AddEntity(role);<br>}<br><br>em.SaveChanges();<br></pre></td></tr></table><br><br>Which used to work fine. But when I cleaned up the db and executed this same code, I'm now getting the following error when adding the 2nd entity to AddEntity():<br><br>"An entity with this key: Role: 0 already exists in this EntityManager"<br><br>The Id is Primary Key and Identity auto-incremented by 1. But somehow the Id is not longer auto-incremented when being added to the EntityManager.<br><br>This is the data property of the RoleId, generated by DevForce:<br><br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;&nbsp;&nbsp; &#091;Key&#093;<br>&nbsp;&nbsp;&nbsp; &#091;DataMember&#093;<br>&nbsp;&nbsp;&nbsp; &#091;Bindable(true, BindingDirection.TwoWay)&#093;<br>&nbsp;&nbsp;&nbsp; &#091;Editable(true)&#093;<br>&nbsp;&nbsp;&nbsp; &#091;Display(Name="Id", AutoGenerateField=true)&#093;<br>&nbsp;&nbsp;&nbsp; &#091;IbVal.RequiredValueVerifier( ErrorMessageResourceName="Role_Id")&#093;<br></pre></td></tr></table><br><br>And the script for the Role table:<br><br><table width="99%"><tr><td><pre class="BBcode"><br>CREATE TABLE &#091;dbo&#093;.&#091;Role&#093;(<br>&nbsp;&nbsp;&nbsp; &#091;Id&#093; &#091;smallint&#093; IDENTITY(1,1) NOT NULL,<br>&nbsp;&nbsp;&nbsp; &#091;Name&#093; &#091;nvarchar&#093;(25) NOT NULL,<br>&nbsp;CONSTRAINT &#091;PK_Role&#093; PRIMARY KEY CLUSTERED <br>(<br>&nbsp;&nbsp;&nbsp; &#091;Id&#093; ASC<br>)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON &#091;PRIMARY&#093;<br>) ON &#091;PRIMARY&#093;<br></pre></td></tr></table><br><br>Could someone be so kind to point me out what is the problem?<br><br>Thanks in advance,<br>Dave<br>]]>
   </description>
   <pubDate>Fri, 06 Dec 2013 19:17:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4623&amp;PID=17296#17296</guid>
  </item> 
 </channel>
</rss>