<?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 : Entity without primary key</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Entity without primary key</description>
  <pubDate>Tue, 28 Apr 2026 01:56:17 -700</pubDate>
  <lastBuildDate>Fri, 20 Feb 2009 15:35:54 -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=1097</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>Entity without primary key : The Entity Framework, or at least...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1097&amp;PID=3930#3930</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> 1097<br /><strong>Posted:</strong> 20-Feb-2009 at 3:35pm<br /><br /><DIV>The Entity Framework, or at least the Entity Data Model Designer, won't allow you to define an Entity without an EntityKey.&nbsp; When you try this the designer gives you an error and the code is not generated.&nbsp; However, when you added the Entity to the model using the designer, it arbitrarily marked some properties as part of the EntityKey when it didn't find a primary key in the table.&nbsp; I guess I shouldn't say this is arbitrary, but I don't actually know what criteria it's using.&nbsp; If you look in the generated entity model you'll see a message like:</DIV><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV>"warning 6002: The table/view 'XX' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view."</DIV></BLOCKQUOTE><DIV>So, you likely had an Entity defined with an "unusual" EntityKey.&nbsp; DevForce then used this EntityKey when the query was run, with&nbsp;unpredictable results.</DIV><DIV>&nbsp;</DIV><DIV>The restriction that an Entity have an EntityKey is both an EF and DevForce EF requirement.&nbsp; EF&nbsp;won't generate its&nbsp;model, and even should this somehow succeed DevForce also insists that every entity have "identity" in the form of a unique EntityKey.&nbsp; This doesn't mean that you must define a primary key on the table, but you must define an EntityKey on the Entity.&nbsp; To do this correctly though&nbsp;requires hand editing the EDMX file to ensure that the storage and conceptual models agree, so defining a PK in the database is probably the easiest way to resolve the issue.</DIV>]]>
   </description>
   <pubDate>Fri, 20 Feb 2009 15:35:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1097&amp;PID=3930#3930</guid>
  </item> 
  <item>
   <title>Entity without primary key : I&amp;#039;m converting a MS Access...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1097&amp;PID=3927#3927</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=38" rel="nofollow">rclarke</a><br /><strong>Subject:</strong> 1097<br /><strong>Posted:</strong> 19-Feb-2009 at 2:13pm<br /><br />I'm converting a MS Access application to SQL server using DevForce EF. Part of my development process involves importing Access tables into the SQL database and then converting the Access table date to the new equivilent SQL Server table. During one such import and subsequent conversion I tried to query the Access Table with the following code:<br><br>Dim startDate As DateTime = Convert.ToDateTime(Me._uxTicketStartDateDateEdit.DateTime)<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dim accessTicketQuery = _<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AEM.Mgr.AccessTicket1.Where(Function(t) t.Ticket_Date.Value &gt;= startDate.Date)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _ticketsFromAccess.ReplaceRange(accessTicketQuery)<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If _ticketsFromAccess.Count = 0 Then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Logger("Query produced no tickets")<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Return<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Logger(String.Format("Query produced {0} tickets", _ticketsFromAccess.Count))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End If<br><br>The query should have returned over 4000 records but only 3 were returned. Upon further examination I found that the imported table did not have a primary key defined so I set the approptiate column in the table as a primary key and the query workes as expected. The full set of records is returned. I know that every table should have a PK but in this case this table will be used only once and deleted. I'm not sure if this is an EF issue or and Devforce issue.<br><br>Thanks,<br><br>Ron<br><br>]]>
   </description>
   <pubDate>Thu, 19 Feb 2009 14:13:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1097&amp;PID=3927#3927</guid>
  </item> 
 </channel>
</rss>