<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx</link><description>Background A number of months ago we asked whether Foreign Keys (FKs) in Conceptual and Object models were important. The feedback we got indicated that there are a real mix of opinions on the topic. Some people are all for them while others think that</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Click &amp;amp; Solve &amp;raquo;  Foreign Keys in the Entity Framework </title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9481977</link><pubDate>Tue, 17 Mar 2009 00:00:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9481977</guid><dc:creator>Click &amp;amp; Solve &amp;raquo;  Foreign Keys in the Entity Framework </dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.clickandsolve.com/?p=23814"&gt;http://www.clickandsolve.com/?p=23814&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Entity Framework Design : Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9482142</link><pubDate>Tue, 17 Mar 2009 02:33:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9482142</guid><dc:creator>DotNetShoutout</dc:creator><description>&lt;p&gt;Thank you for submitting this cool story - Trackback from DotNetShoutout&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9482305</link><pubDate>Tue, 17 Mar 2009 05:52:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9482305</guid><dc:creator>Michael Hart</dc:creator><description>&lt;p&gt;Code snippet #3, with the editedProduct doesn't seem to make much sense to me.&lt;/p&gt;
&lt;p&gt;Where does newProduct come from? Shouldn't you just attach the editedProduct directly (which will have the updated Category/ID in it)?&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9482324</link><pubDate>Tue, 17 Mar 2009 06:05:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9482324</guid><dc:creator>Alex James</dc:creator><description>&lt;p&gt;Michael,&lt;/p&gt;
&lt;p&gt;there was a typo... it was suppose to be editedProduct...&lt;/p&gt;
&lt;p&gt;Let me know if it still doesn't make sense&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9482379</link><pubDate>Tue, 17 Mar 2009 07:00:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9482379</guid><dc:creator>KristoferA</dc:creator><description>&lt;p&gt;I'm with Michael here - why not context.Products.Attach(editedProduct); ?&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9483144</link><pubDate>Tue, 17 Mar 2009 12:47:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9483144</guid><dc:creator>cravier</dc:creator><description>&lt;p&gt;Really good news !&lt;/p&gt;
&lt;p&gt;I had to manage this on current EF release and it gave me a big headhache to keep FK and references sync.&lt;/p&gt;
&lt;p&gt;I still have some problems (setting FKs in constructor for example) but I'll now wait for next release instead of adding some code in my framework.&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9484094</link><pubDate>Tue, 17 Mar 2009 20:01:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9484094</guid><dc:creator>efdesign</dc:creator><description>&lt;p&gt;Kristofer and Michael,&lt;/p&gt;
&lt;p&gt;The idea is to create a fake entity and attach that, to save the query to the database. And then to modify that with the values, including the FK value, in editedProduct with a call to ApplyCurrentValues().&lt;/p&gt;
&lt;p&gt;At this point the EF knows the new state of the product and knows that it is modified.&lt;/p&gt;
&lt;p&gt;Does that make sense?&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9485813</link><pubDate>Wed, 18 Mar 2009 07:23:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9485813</guid><dc:creator>KristoferA</dc:creator><description>&lt;p&gt;But you can do that by attaching the existing editedProduct instance too.&lt;/p&gt;
&lt;p&gt;It is a basic n-tier scenario; get object, serialize/disconnect, do stuff, re-attach, update. Much cleaner if it can be done in one step IMO...&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9488047</link><pubDate>Thu, 19 Mar 2009 00:05:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9488047</guid><dc:creator>Mike Borozdin</dc:creator><description>&lt;p&gt;Alex,&lt;/p&gt;
&lt;p&gt;Good work! I'm really happy that the new version of the Entity Framework will a lot better and easy to use than the current version.&lt;/p&gt;
&lt;p&gt;Currently, I'm working with the version in .NET 3.5 SP1 it provides a really great level of abstraction, but sometimes it's difficult to write code mainly because of absense of foreign keys in the conceptual model.&lt;/p&gt;
</description></item><item><title>Новая версия Entity Framework будет поддерживать внешние ключи в концептуальной </title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9488121</link><pubDate>Thu, 19 Mar 2009 00:29:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9488121</guid><dc:creator>Mike Borozdin</dc:creator><description>&lt;p&gt;Многие, кто сейчас работают с Entity Framework, жалуются на отсутствие внешних к&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9493343</link><pubDate>Fri, 20 Mar 2009 22:51:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9493343</guid><dc:creator>shawn</dc:creator><description>&lt;p&gt;Great to hear this, it will make dealing with foreign keys much easier!&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9502214</link><pubDate>Mon, 23 Mar 2009 21:44:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9502214</guid><dc:creator>Jon</dc:creator><description>&lt;p&gt;Does anyone know if Entity Framework will be usable in .NET 4? Or, is this blog just a bunch of hot air for another Microsoft ORM that will never see the light of day? What about generating the database schema from the model? Is that going to be supported? Why can't Microsoft get this stuff right and somehow open source projects like NHibernate are able to figure it out? I don't know why EF was even included in .NET 3.5.&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9502688</link><pubDate>Tue, 24 Mar 2009 00:57:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9502688</guid><dc:creator>AlexJ</dc:creator><description>&lt;p&gt;Jon,&lt;/p&gt;
&lt;p&gt;Generating a database from a model is a supported scenario in the next version of the Entity Framework (.NET 4.0) see the post on &amp;quot;Model First&amp;quot; on this blog.&lt;/p&gt;
&lt;p&gt;As for your other concerns and questions. we know we didn't get everything right in .NET 3.5, but we are listening to what our customers have been saying and are doing our best to rectify the situation for .NET 4.0, which will be a major improvement.&lt;/p&gt;
&lt;p&gt;Other than &amp;quot;model first&amp;quot; have you got any specific concerns with the first version of the Entity Framework? If so I'd love to hear from you. My email is alexj at microsoft dot com.&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;
</description></item><item><title>New posts on EF Design Blog</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9503220</link><pubDate>Tue, 24 Mar 2009 05:42:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9503220</guid><dc:creator>Jaroslaw Kowalski</dc:creator><description>&lt;p&gt;I’d like to turn your attention to two blog posts on EF Design Blog about exciting new features planned&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9506113</link><pubDate>Wed, 25 Mar 2009 05:25:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9506113</guid><dc:creator>Y2Kstephen</dc:creator><description>&lt;p&gt;GREAT !!!&lt;/p&gt;
&lt;p&gt;i can't wait any longer for .NET 4.0 !!!&lt;/p&gt;
</description></item><item><title>Tip 7 - Faking Foreign Key Properties in .NET 3.5 SP1</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9506154</link><pubDate>Wed, 25 Mar 2009 05:43:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9506154</guid><dc:creator>Meta-Me</dc:creator><description>&lt;p&gt;Background If you've been reading the EF Design Blog you will have seen that we recently announced something&lt;/p&gt;
</description></item><item><title>Tip 9 – Deleting an object without retrieving it</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9513153</link><pubDate>Fri, 27 Mar 2009 08:38:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9513153</guid><dc:creator>Meta-Me</dc:creator><description>&lt;p&gt;Problem The most common way to delete an Entity in the Entity Framework is to pull the Entity you want&lt;/p&gt;
</description></item><item><title>Schema et accès aux données</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9521727</link><pubDate>Tue, 31 Mar 2009 09:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9521727</guid><dc:creator>Les news d'Aspectize</dc:creator><description>&lt;p&gt;Cet article a pour objectif de d&amp;#233;crire notre approche &amp;#224; propos de l&amp;amp;#39;acc&amp;#232;s aux donn&amp;#233;es. En pr&amp;#233;ambule&lt;/p&gt;
</description></item><item><title>Tip 10 - Understanding Entity Framework jargon</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9530181</link><pubDate>Fri, 03 Apr 2009 07:41:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9530181</guid><dc:creator>Meta-Me</dc:creator><description>&lt;p&gt;The Entity Framework is pretty big, so when the Entity Framework team talks about things internally we&lt;/p&gt;
</description></item><item><title>An analogy: Good UI and Fluent APIs</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9553407</link><pubDate>Thu, 16 Apr 2009 22:27:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9553407</guid><dc:creator>Meta-Me</dc:creator><description>&lt;p&gt;Background A while back I was writing a web app to try the Entity Framework and MVC together. I knew&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9599654</link><pubDate>Sun, 10 May 2009 00:41:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9599654</guid><dc:creator>Baum</dc:creator><description>&lt;p&gt;Are there any plans for Microsoft to include EF 2.0 support for databases other than SQL Server such as Oracle or DB2. I know that there is a 3rd part provider that allows EF 1.0 to work with Oracle, but it would be nice if Microsoft provided support out-of-the-box.&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9616137</link><pubDate>Thu, 14 May 2009 17:33:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9616137</guid><dc:creator>Daniel Simmons</dc:creator><description>&lt;p&gt;@Baum,&lt;/p&gt;
&lt;p&gt;There are not plans for Microsoft to ship EF providers for databases outside of the SQL family--except for some work that the Host Integration Server team is doing around DB2. &amp;nbsp;For databases such as Oracle, we will depend on 3rd parties (or Oracle itself) to create those providers.&lt;/p&gt;
&lt;p&gt;- Danny&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9751101</link><pubDate>Sun, 14 Jun 2009 19:17:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9751101</guid><dc:creator>Alexander Walker</dc:creator><description>&lt;p&gt;I'm using vs2010 beta 1. I created a .net 4.0 console project, added an empty ADO.NET Entity Model, then performed the steps detailed above for FK Associations for the Model First scenario. I found that I could not make the foreign key association in step 4, the CategoryID was not in the Dependant Property dropdown and typing it in didn't work either, is this a bug or did I miss something out?&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9751226</link><pubDate>Sun, 14 Jun 2009 19:41:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9751226</guid><dc:creator>divega@microsoft.com</dc:creator><description>&lt;p&gt;@Alexander,&lt;/p&gt;
&lt;p&gt;Beta 1 doesn’t actually include support for Foreign Key Associations. You can expect the feature to be there in the next publically available release. &lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Diego&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9777117</link><pubDate>Thu, 18 Jun 2009 22:17:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9777117</guid><dc:creator>Paul</dc:creator><description>&lt;p&gt;Thanks for the interesting information. &lt;/p&gt;
&lt;p&gt;Will it be possibly for the EF to generate the FK properties automatically? If you have a huge data model this will be a big hassle. &lt;/p&gt;
&lt;p&gt;Maybe, I'm a special case because we have our own data layer, but I'm fundamentally interested in having classes generated that can be mapped directly onto the underlying data columns. &lt;/p&gt;
&lt;p&gt;Currently, I've been trying to figure out how to have the current entity framework completely ignore foreign key associations. Anybody know if this is possible? &lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;
</description></item><item><title>Tip 26 – How to avoid database queries using Stub Entities</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9791409</link><pubDate>Fri, 19 Jun 2009 21:00:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9791409</guid><dc:creator>Meta-Me</dc:creator><description>&lt;p&gt;What are Stub Entities? A stub entity is a partially populated entity that stands in for the real thing.&lt;/p&gt;
</description></item><item><title>Tip 26 – How to avoid database queries using Stub Entities</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9792666</link><pubDate>Sat, 20 Jun 2009 05:36:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9792666</guid><dc:creator>VS2010学习</dc:creator><description>&lt;p&gt;What are Stub Entities? A stub entity is a partially populated entity that stands in for the real thing&lt;/p&gt;
</description></item><item><title>Tip 10 - How to understand Entity Framework jargon</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9795991</link><pubDate>Sun, 21 Jun 2009 21:30:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9795991</guid><dc:creator>VS2010学习</dc:creator><description>&lt;p&gt;The Entity Framework is pretty big, so when the Entity Framework team talks about things internally we&lt;/p&gt;
</description></item><item><title>Tip 9 – How to delete an object without retrieving it</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9795994</link><pubDate>Sun, 21 Jun 2009 21:31:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9795994</guid><dc:creator>VS2010学习</dc:creator><description>&lt;p&gt;Problem The most common way to delete an Entity in the Entity Framework is to pull the Entity you want&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9829311</link><pubDate>Sat, 11 Jul 2009 08:36:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9829311</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;I think a better way to go about this would be to be able to create entity proxies that only have the ID/primary key properties populated. Once you access another property, it would load the entity data from the database. This way you can assign relations without hitting the database or redundant properties.&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9895060</link><pubDate>Mon, 14 Sep 2009 20:42:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895060</guid><dc:creator>Fedir</dc:creator><description>&lt;p&gt;I've tried to use the &amp;quot;FK Association&amp;quot; in the VS2010 Beta1 and DataServices CTP2 release - it doesn't &amp;nbsp;work as were outlined in this article. You can't create an FK association on the dependent object property if its not a part of the entity key!? Why this was changed and how can I work with the &amp;quot;FK association&amp;quot; now?&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9895112</link><pubDate>Mon, 14 Sep 2009 22:50:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895112</guid><dc:creator>Daniel Simmons</dc:creator><description>&lt;p&gt;#Fedir,&lt;/p&gt;
&lt;p&gt;This wasn't &amp;quot;changed&amp;quot;. &amp;nbsp;This feature just hasn't been released yet. &amp;nbsp;FK Associations will be in beta 2 of VS2010, but it hadn't yet made it into the product as of beta 1. &amp;nbsp;Sorry, but you have a little while to wait yet.&lt;/p&gt;
&lt;p&gt;- Danny&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9906063</link><pubDate>Mon, 12 Oct 2009 10:03:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9906063</guid><dc:creator>Andrey</dc:creator><description>&lt;p&gt;If I've not missed something, so please note that IObjectSet in Beta1 contains small amount of possible methods from ObjectSet, so the scenario #3 could not be covered unit tests (by mocking ObjectSet) at all because of using ApplyCurrentValues method. Is it possible to enlarge IObjectSet interface with that methods or introduce new interface for that.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9906509</link><pubDate>Tue, 13 Oct 2009 08:20:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9906509</guid><dc:creator>Aquilax</dc:creator><description>&lt;p&gt;I hope this will also improve the performance of the Data Services. Actually the Data Services doesn't include any information about related object / foreign keys, to have them you have to $expand the relation, what sometimes generate only a bigger response and it is useless.&lt;/p&gt;
&lt;p&gt;For example I want to load a product, on the client I have already loaded all the available product categories, so I really don't need to $expand the product category relation to have it but if I don't do it I don't have it. &lt;/p&gt;
&lt;p&gt;Now if my product have 6 different relations to some mapping tables (which I have already loaded on the client) and I show 20 products per page, the Data Services includes to each request 20x6=120 completely useless informations, which make only the response bigger and worse the performance of the application.&lt;/p&gt;
&lt;p&gt;Instead of the foreign key could have also been used a &amp;quot;ghost&amp;quot; entity, which contains only the primary key. A &amp;quot;ghost&amp;quot; entity can interpreted as &amp;quot;this entity exists but it has not yet materialized&amp;quot;. So loading entities from the DB without including referenced entities will generated &amp;quot;ghost&amp;quot; entities for all the relations which are not null. &lt;/p&gt;
&lt;p&gt;So for example to change the category of a product could be done by just assigning a new &amp;quot;ghost&amp;quot; entity to the product:&lt;/p&gt;
&lt;p&gt;//Create a &amp;quot;ghost&amp;quot; entity with a static method&lt;/p&gt;
&lt;p&gt;product.Category = Category.Ghost(3);&lt;/p&gt;
&lt;p&gt;//Create a &amp;quot;ghost&amp;quot; entity with a regular constructor&lt;/p&gt;
&lt;p&gt;product.Category = new Category(true){Id=3};&lt;/p&gt;
&lt;p&gt;Moreover it would be nice if &amp;quot;ghost&amp;quot; entity could also been materialized, this means load the entity from the DB:&lt;/p&gt;
&lt;p&gt;//Loading a product without including the relations&lt;/p&gt;
&lt;p&gt;Product product = context.Product.Where(p =&amp;gt; p.Id==3).First();&lt;/p&gt;
&lt;p&gt;//Materializing the category relation = loading it&lt;/p&gt;
&lt;p&gt;product.Category.Materialize();&lt;/p&gt;
</description></item><item><title>re: Foreign Keys in the Entity Framework</title><link>http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspx#9914478</link><pubDate>Thu, 29 Oct 2009 03:06:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9914478</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi Alex,&lt;/p&gt;
&lt;p&gt;Scenario 1 represents the greatest improvement among the scenarios presented. Please continue to strive for this level of simplicity. &lt;/p&gt;
&lt;p&gt;I have to agree with Kristofer and Michael regarding scenario 3 though. This is another convoluted solution for something that has an obviously simple solution. I get your explanation of the scenario. I don't get why these steps couldn't be placed within the attach method itself. Doing so would increase the value of the EF because it would make the EF more intuitive. As it is, I look at it, scratch my head, and hope its a typo. Just like I did when reading about the use/necessity of EntityKeys. Simplicity is king. &lt;/p&gt;
&lt;p&gt;This may seem like a goofy recommendation, but I think the EF team would benefit from hiring an information architect/interface designer (not a Comp Sci grad and not someone who bleeds MS). Someone who can bridge the gap between the users and the EF team. Just a suggestion. &lt;/p&gt;
&lt;p&gt;I think the product shows huge potential and I want it to be successful. Mostly because I want to spend more time building apps and less time programming/struggling with the eccentricities of my tools.&lt;/p&gt;
&lt;p&gt;Thanks for hearing me out...&lt;/p&gt;
&lt;p&gt;- Jason&lt;/p&gt;
</description></item></channel></rss>