<?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>Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx</link><description>Since the release of the Entity Framework, we have received a number of requests for details and best practices from customers who are looking at migrating their LINQ to SQL based applications to the Entity Framework.&amp;#160; In order to address this topic,</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>  Migrating from LINQ to SQL to Entity Framework: Eager Loading : EasyCoded</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8990634</link><pubDate>Wed, 08 Oct 2008 08:07:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8990634</guid><dc:creator>  Migrating from LINQ to SQL to Entity Framework: Eager Loading : EasyCoded</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.easycoded.com/migrating-from-linq-to-sql-to-entity-framework-eager-loading/"&gt;http://www.easycoded.com/migrating-from-linq-to-sql-to-entity-framework-eager-loading/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8991062</link><pubDate>Wed, 08 Oct 2008 12:23:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991062</guid><dc:creator>Jay</dc:creator><description>&lt;p&gt;When is the next release of Entity Framework scheduled?&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8991122</link><pubDate>Wed, 08 Oct 2008 13:22:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991122</guid><dc:creator>Ido Flatow</dc:creator><description>&lt;p&gt;Unfortunately, .Include supports loading only one related end, thus making us load each and every related end by code. I'd think that there should be something like .Include(&amp;quot;*&amp;quot;) to load all referenced entities, and event .Include(&amp;quot;*/*&amp;quot;) for getting all cascaded entities. If i'm writing a service that returns an entity with all related data, I won't want to start writing numerous lines of code, just to mention that &amp;quot;oh, yes, of course I want to return ALL the data of the entity&amp;quot;.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8991127</link><pubDate>Wed, 08 Oct 2008 13:37:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991127</guid><dc:creator>Paul Blamire</dc:creator><description>&lt;p&gt;Nice work. Looking forward to the rest of this series&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8991578</link><pubDate>Wed, 08 Oct 2008 19:04:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991578</guid><dc:creator>Joseph F</dc:creator><description>&lt;p&gt;Fantastic! I've always hated the way LINQ2SQL handled eager fetching. But, where is the strong typing. A string just doesn't seem like the ideal way of specifying this.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8991610</link><pubDate>Wed, 08 Oct 2008 19:22:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991610</guid><dc:creator>divega</dc:creator><description>&lt;p&gt;Hello Ido,&lt;/p&gt;
&lt;p&gt;Something like Include(&amp;quot;*&amp;quot;) is intentionally not supported. While the Include API makes it easy to modify a query for it to load related information, each related end that you add comes at a cost. &lt;/p&gt;
&lt;p&gt;Loading multiple paths and/or multiple levels, very quickly results in extremely complex queries. &lt;/p&gt;
&lt;p&gt;My recommendation is to eager load only what is needed, always adding related ends and levels one at a time. As soon as you see any performance degradation, go one step back and try using other techniques. Sometimes it may help to do explicit load (as an example, it is not necessary to expand all orders, only the one you are displaying details for). &lt;/p&gt;
&lt;p&gt;Other times you may want to take advantage of the relationship fix-up that we do for tracked queries. As an example, you can load Orders and the corresponding OrderLines in two separate AppendOnly queries. Once you have loaded the results of both queries, the stack will have fixed-up all relationships, so you will find each order’s OrderLines collection is loaded. &lt;/p&gt;
&lt;p&gt;Diego&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8991657</link><pubDate>Wed, 08 Oct 2008 19:46:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8991657</guid><dc:creator>Craig Stuntz</dc:creator><description>&lt;p&gt;How do you eager load properties of a subtype? For example, let's say I have a type Department which has a navigation property (0..1) Chairman of type Employee. &amp;nbsp;Some of the employees are Managers. &amp;nbsp;Managers has a Supervises property which returns a list of Employees. &amp;nbsp;When I eager load the department Chairman, I would also like to eager load all Employees supervised if the Chairman is a Manager.&lt;/p&gt;
&lt;p&gt;In other words, something like this (I'm making up the syntax):&lt;/p&gt;
&lt;p&gt;.Include(&amp;quot;Chairman&amp;quot;).Include(&amp;quot;(Chairman as Manager).Employees&amp;quot;).&lt;/p&gt;
&lt;p&gt;?&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8992079</link><pubDate>Thu, 09 Oct 2008 00:33:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8992079</guid><dc:creator>Mark Smeltzer</dc:creator><description>&lt;p&gt;Regarding the use of strings... here is a comment I posted on the EF design blog a few days ago:&lt;/p&gt;
&lt;p&gt;Hey Guys,&lt;/p&gt;
&lt;p&gt;It would be really helpful if the code generators could generate a layer of abstractions that contained all of the string constants that are used in the attributes. Currently, it is a real pain that we often need to use string constants when doing things like eSQL or Include()'s.&lt;/p&gt;
&lt;p&gt;I wrote my own little utility to parse through the XML bits, and generate classes to do the job for me, but it would be great if this were available for everyone as part of the toolset.&lt;/p&gt;
&lt;p&gt;The classes I generate a just a series of nested static classes that allow me to write things like &amp;quot;MyDbContextMetadata.Entities.Customer .Properties.PhoneNumber.PropertyName&amp;quot; or &amp;quot;MyDbContextMetadata.Entities.Customer .Relationships.Supplier.Properties.Id.PropertyName&amp;quot;.&lt;/p&gt;
&lt;p&gt;That stuff is certainly a bit verbose, but the key benefit is that when model changes so will the metadata structures. Thus, any invalid metadata references will generate compilation errors rather than runtime errors.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8992903</link><pubDate>Thu, 09 Oct 2008 17:47:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8992903</guid><dc:creator>Travis Plummer</dc:creator><description>&lt;p&gt;I second the request by Craig Stuntz. Self joins with subtyped nodes are common and we don't want to recursively load these relationships. When I give the children\nav property name with include, why can't it resolve n levels deep for me? &lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Travis&lt;/p&gt;
</description></item><item><title>Weekly digest of interesting stuff</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8993965</link><pubDate>Fri, 10 Oct 2008 12:51:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8993965</guid><dc:creator>Steve Strong's Blog</dc:creator><description>&lt;p&gt;Weekly digest of interesting stuff&lt;/p&gt;
</description></item><item><title>Migrating from LINQ To SQL to the Entity Framework</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#8997915</link><pubDate>Mon, 13 Oct 2008 15:48:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8997915</guid><dc:creator>Swiss MSDN Team Blog</dc:creator><description>&lt;p&gt;Since the release of the Entity Framework, Microsoft got a number of requests for details and best practices&lt;/p&gt;
</description></item><item><title>Migrating from LINQ to SQL to Entity Framework: Deferred Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9002050</link><pubDate>Thu, 16 Oct 2008 20:52:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9002050</guid><dc:creator>ADO.NET team blog</dc:creator><description>&lt;p&gt;Last week, we covered Eager Loading and how to migrate LINQ to SQL based code that took advantage of&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9003471</link><pubDate>Fri, 17 Oct 2008 21:27:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9003471</guid><dc:creator>Guy Hurst</dc:creator><description>&lt;p&gt;Eager loading in EF apparently has limitations on SQL2000 - we weren't able to Include() nested levels, and had to use separate Load() calls after completing the initial query. &lt;/p&gt;
&lt;p&gt;In other words, we had to use multiple sequential queries. &lt;/p&gt;
&lt;p&gt;However, when we used SQL2005 as the underlying DB, with MARS enabled, the nested Include()'s worked fine. Does this mean EF requires MARS (Multiple Active Result Sets) to do nested Include()'s ? And by extension, does it therefore need MARS to fully support eager loading?&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9003501</link><pubDate>Fri, 17 Oct 2008 21:45:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9003501</guid><dc:creator>Guy Hurst</dc:creator><description>&lt;p&gt;Let me modify my previous comment by specifying that the nested Include()'s that failed were not just nested, but were to the same underlying table. Several Navigation Properties of the entity being queried were actually associating to the same underlying table, and this seems to have been the source of the conflict.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9030325</link><pubDate>Mon, 03 Nov 2008 04:47:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9030325</guid><dc:creator>shawn</dc:creator><description>&lt;p&gt;I'm in agreement with Joseph and Mark's comments, if we can get an option for strongly-typed Include statements to use as an option instead of strings that would be great. &amp;nbsp;After using LINQ to get away from strings of SQL it is unfortunate to have to embed strings back in as part of Includes. &amp;nbsp;It just seems a little brittle.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9426959</link><pubDate>Tue, 17 Feb 2009 06:00:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9426959</guid><dc:creator>Daniel</dc:creator><description>&lt;p&gt;A few things I have noticed in the Comments, some said they didn't like the use of a string in the &amp;quot;include&amp;quot; (no strong typing), and I also saw someone say it does not support multuple levels of associated entities.&lt;/p&gt;
&lt;p&gt;As far as strong typing the query as opposed to writing the table name in it, I haven't seen a clever way around that, the closest I can get is:&lt;/p&gt;
&lt;p&gt;Instead of this:&lt;/p&gt;
&lt;p&gt;Product firstProduct = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db.Product.Include(&amp;quot;OrderDetail&amp;quot;).Include(&amp;quot;Supplier&amp;quot;).First();&lt;/p&gt;
&lt;p&gt;Write this:&lt;/p&gt;
&lt;p&gt;Product firstProduct = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db.Product.Include(db.OrderDetail.CommandText).Include(db.Supplier.CommentText).First();&lt;/p&gt;
&lt;p&gt;And as far as supporting multiple levels, you can write something like this:&lt;/p&gt;
&lt;p&gt;Product firstProduct = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db.Product.Include(db.OrderDetail.CommandText + &amp;quot;.&amp;quot; + db.OrderDetailLevel2.CommandText).Include(db.Supplier.CommentText + &amp;quot;.&amp;quot; + db.SupplierLevel2.CommandText).First();&lt;/p&gt;
&lt;p&gt;You see, the &amp;quot;Include&amp;quot; accepts a &amp;quot;dot-delimited&amp;quot; list of an existing path of associated entities&lt;/p&gt;
&lt;p&gt;Hope this helps somebody! &lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9440048</link><pubDate>Sun, 22 Feb 2009 14:03:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9440048</guid><dc:creator>stuartle</dc:creator><description>&lt;p&gt;I wrote a blog post last year about a possible way to use Include with expressions rather than strings in Entity Framework:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/stuartleeks/archive/2008/08/27/improving-objectquery-t-include.aspx"&gt;http://blogs.msdn.com/stuartleeks/archive/2008/08/27/improving-objectquery-t-include.aspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9547192</link><pubDate>Mon, 13 Apr 2009 22:55:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9547192</guid><dc:creator>Jim Wooley</dc:creator><description>&lt;p&gt;Daniel,&lt;/p&gt;
&lt;p&gt;Instead of using the CommandText to supply a string representation of the object to be &amp;quot;Included&amp;quot;, why not support an expression predicate as LINQ to SQL does in the LoadWith option. That provides a richer option as you can not only strongly type the child relationship, but can also add filtering as well. Thus you could have:&lt;/p&gt;
&lt;p&gt;Product firstProduct = db.Product.Include(p =&amp;gt; p.OrderDetail);&lt;/p&gt;
&lt;p&gt;Or &lt;/p&gt;
&lt;p&gt;Product firstProduct = db.Product.Include(p =&amp;gt; p.OrderDetail.OfType&amp;lt;ActiveOrders&amp;gt;());&lt;/p&gt;
&lt;p&gt;Of course this would entail parsing more expression trees as part of the query evaluation, but could provide a much richer implementation.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9620028</link><pubDate>Sat, 16 May 2009 01:13:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9620028</guid><dc:creator>Non-Migrator</dc:creator><description>&lt;p&gt;Since Entity Framework doesn't even support enumerations, why would people want to migrate away? &amp;nbsp;I guess there are some advanced scenarios where a person would need to, but IMO, Entity Framework just isn't developed enough yet. &amp;nbsp;Agree? &amp;nbsp;Disagree?&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9635038</link><pubDate>Fri, 22 May 2009 14:05:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9635038</guid><dc:creator>Medyum</dc:creator><description>&lt;p&gt; I also saw someone say it does not support multuple levels of associated entities.&lt;/p&gt;
&lt;p&gt;As far as strong typing the query as opposed to writing the table name in it, I haven't seen a clever way around that, the closest I can get is:&lt;/p&gt;
&lt;p&gt;Instead of this:&lt;/p&gt;
&lt;p&gt;Product firstProduct = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db.Product.Include(&amp;quot;OrderDetail&amp;quot;).Include(&amp;quot;Supplier&amp;quot;).First();&lt;/p&gt;
&lt;p&gt;Write this:&lt;/p&gt;
&lt;p&gt;Product firstProduct = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db.Product.Include(db.OrderDetail.CommandText).Include(db.Supplier.CommentText).First();&lt;/p&gt;
&lt;p&gt;And as far as supporting multiple levels, you can write something like this:&lt;/p&gt;
&lt;p&gt;Product firstProduct = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db.Product.Include(db.OrderDetail.CommandText + &amp;quot;.&amp;quot; + db.OrderDetailLevel2.CommandText).Include(db.Supplier.CommentText + &amp;quot;.&amp;quot; + db.SupplierLevel2.CommandText).First();&lt;/p&gt;
&lt;p&gt;You see, the &amp;quot;Include&amp;quot; accepts a &amp;quot;dot-delimited&amp;quot; list of an existing path of associated entities&lt;/p&gt;
&lt;p&gt;Hope this helps somebody! &lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9817688</link><pubDate>Sat, 04 Jul 2009 22:28:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9817688</guid><dc:creator>hikaye</dc:creator><description>&lt;p&gt;This is fantastic. I am going to add it to my sites. Thanks!&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9846388</link><pubDate>Thu, 23 Jul 2009 17:38:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9846388</guid><dc:creator>ssk sorgulama</dc:creator><description>&lt;p&gt;Fantastic! I've always hated the way LINQ2SQL handled eager fetching. But, where is the strong typing. A string just doesn't seem like the ideal way of specifying this.&lt;/p&gt;
</description></item><item><title>re: Migrating from LINQ to SQL to Entity Framework: Eager Loading</title><link>http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx#9846579</link><pubDate>Thu, 23 Jul 2009 19:53:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9846579</guid><dc:creator>zerrin egeliler</dc:creator><description>&lt;p&gt;This is fantastic. I am going to add it to my sites. Thanks!&lt;/p&gt;
</description></item></channel></rss>