<?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>Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx</link><description>Today I thought I would talk about a really common scenario in data applications, creating a master-details (one-to-many) data entry form. I’ve written about WPF data binding and Entity Framework a lot in the past: 
 Posts: 
 
 Master-Details with</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10174032</link><pubDate>Mon, 13 Jun 2011 19:28:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10174032</guid><dc:creator>wagenb</dc:creator><description>&lt;p&gt;Hi Beth, great video series on WPF/EF. I used your sample to build 2 Master Detail applications for my 1st WPF application. How would I incorporate data validation on the listview data?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10174032" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10132129</link><pubDate>Mon, 21 Feb 2011 11:29:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10132129</guid><dc:creator>mr anto</dc:creator><description>&lt;p&gt;hi beth,&lt;/p&gt;
&lt;p&gt;im a .Net newbie. My question is: is there a way to create and manage a master/details relation only by VB code? &lt;/p&gt;
&lt;p&gt;In my Window.Xaml I created two DataGrids, masterDataGrid and detailsDataGrid, which should be linked to TAB_MASTER and TAB_DETAILS DB tables. No binding is set in my XAML code.&lt;/p&gt;
&lt;p&gt;Then, in VB code, I created a DataSet, two CollectionViewSource objects, vMaster and vDetails; I loaded them with data from my tables, and bound them to my data grids by these statements:&lt;/p&gt;
&lt;p&gt;masterDataGrid.ItemsSource = vMaster.View&lt;/p&gt;
&lt;p&gt;detailsDataGrid.ItemsSource = vDetails.View&lt;/p&gt;
&lt;p&gt;when I run my application, data are loaded to the grids; but changing the masterDataGrid selected item, detailsDataGrid is not refreshed. If I create my relation at design time, all works. Where is the bug? Please help, thanks&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10132129" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10090683</link><pubDate>Sat, 13 Nov 2010 23:54:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10090683</guid><dc:creator>Siggy</dc:creator><description>&lt;p&gt;HI Beth, thanks for your post.&lt;/p&gt;
&lt;p&gt;Do you have any posts/videos using a DataGrid rather than a ListView object bound to Entity Framework? &amp;nbsp;I am having problems replicating your master-detail example using a DataGrid and would appreciate being able to work through such an example.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10090683" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10084549</link><pubDate>Tue, 02 Nov 2010 05:33:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10084549</guid><dc:creator>Anwar</dc:creator><description>&lt;p&gt;Dear Beth , i have gone through your c# version of masterdetail with Entity framework, the issue is with MasterView.AddNew, when there is data in the order and order details table , your app works fine , but when i deleted the data in both these table, it fails giving the follwing error because MasterView.AddNew.CanAddNew = false.&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;#39;AddNew&amp;#39; is not allowed for this view&amp;quot;.&lt;/p&gt;
&lt;p&gt;can you please tell me how to overcome this with C# &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10084549" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10057446</link><pubDate>Thu, 02 Sep 2010 20:32:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10057446</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;Hi Tim, here are a couple explanations from the EF Team:&lt;/p&gt;
&lt;p&gt;1. The POCO template allows for POCO change tracking proxies. This means that when you get an entity form the database, the actual runtime type of the collection navigation properties are going to be EntityCollection&amp;lt;T&amp;gt;, and not the ObservableCollection based collections that you get when you create a new instance of an entity using “new”. &lt;/p&gt;
&lt;p&gt;2. EntityCollection&amp;lt;T&amp;gt; implements IListSource.GetList that returns an IBindingList and has AssociationChanged, but the default ObservableCollections you get in new instances don’t. That is proabably why sometimes you see BindingListCollectionView on existing entities and ListCollectionView on new entities.&lt;/p&gt;
&lt;p&gt;3. You can use ObjectContext.CreateObject&amp;lt;TEntity&amp;gt;() instead of new to obtain a proxy for a new entity. The proxy will have EntityCollection&amp;lt;T&amp;gt; instances in its collection properties.&lt;/p&gt;
&lt;p&gt;4. Not sure what the behavior is for AssociationChanged in added entities, but suspect it won’t help in a detached entity: don’t think you will get AssociationChanged until the new entity gets actually added to its set.&lt;/p&gt;
&lt;p&gt;5. While you don’t get AssociatedChanged on the collections of new instances, they are based on ObservableCollection&amp;lt;T&amp;gt;, so you could listen to the CollectionChanged event to learn about changes.&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-Beth&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10057446" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10053276</link><pubDate>Mon, 23 Aug 2010 19:11:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10053276</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Hi Beth,&lt;/p&gt;
&lt;p&gt;I have implemented a version of your example using the POCO Template objects instead of interacting directly with EF. &amp;nbsp;This means I do not have access to the AssociationChanged events in my ObservableCollection. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am not sure if this is the cause but when I try to add a new MasterRecord the DetailViewSource.View becomes a ListCollectionView instead of a BindingListCollectionView. (In the MasterView_CurrentChanged function.) &amp;nbsp;Can you provide any help?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10053276" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10009650</link><pubDate>Sat, 08 May 2010 17:14:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009650</guid><dc:creator>Giancarlo</dc:creator><description>&lt;p&gt;P.S.: I have tried adding the OMS db to the server using sql server management studio and it works &lt;/p&gt;
&lt;p&gt;BUT &lt;/p&gt;
&lt;p&gt;if I copy the same db to the project folder and use it in the project to create the OMSmodel etc, this error occurs.&lt;/p&gt;
&lt;p&gt;There is something missing because it happens only for the order query, the &amp;#171;Dim customers = From ...&amp;#187; works in both ways.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009650" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#10009568</link><pubDate>Sat, 08 May 2010 12:36:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009568</guid><dc:creator>Giancarlo</dc:creator><description>&lt;p&gt;I have another error which I can't locate.&lt;/p&gt;
&lt;p&gt;I run the application in debug, just after the line&lt;/p&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;Dim orders = From o In db.Orders _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Where o.OrderDate &amp;gt;= #1/1/2009# _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Order By o.OrderDate Descending, _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; o.Customer.LastName, o.Customer.FirstName _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Select o&lt;/p&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;if I move the mouse over the word &amp;quot;orders&amp;quot; I get the exception error &amp;#171;the name of the column 'Modified' is not valid&amp;#187; (I have translated literally, I have the italian version of vbexpress).&lt;/p&gt;
&lt;p&gt;There is no mention of the column in the instruction, the name in the db is correct, I don't understand why an error and, above all, HOW the above instruction is connected to that column.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009568" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#9997516</link><pubDate>Fri, 16 Apr 2010 22:22:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9997516</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;@GG @Giancarlo,&lt;/p&gt;
&lt;p&gt;The only thing I can suggest is to make sure the database is accessible. Tyr to create a manual connection to it in code. It sounds like EF cannot connect the the database. &lt;/p&gt;
&lt;p&gt;You probably want to ask your question on the EF forum:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/"&gt;http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-B&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9997516" width="1" height="1"&gt;</description></item><item><title>re: Master-Detail Data Binding in WPF with Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/07/14/master-detail-data-binding-in-wpf-with-entity-framework.aspx#9994677</link><pubDate>Mon, 12 Apr 2010 20:49:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9994677</guid><dc:creator>Giancarlo</dc:creator><description>&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;I have the same error as GG.&lt;/p&gt;
&lt;p&gt;I thought I had made some mistakes so I downloaded the code but I get the same error in &lt;/p&gt;
&lt;p&gt;CustomerCollection.vb&lt;/p&gt;
&lt;p&gt; Sub New(ByVal customers As IEnumerable(Of Customer), ByVal context As OMSEntities)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyBase.New(customers)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_context = context&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;End Sub&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9994677" width="1" height="1"&gt;</description></item></channel></rss>