A random spillage of programming (and other) thoughts

Archive for October, 2008

Setting a Silverlight canvas to full width/height of the browser in Silverlight 2

Posted by Michael Bray on October 19, 2008

This article shows how to set the canvas width and height for the page, but apparently some things broke since the page was written and Silverlight 2 came out.  In order to do this properly in Silverlight 2, use Application.Current.Host.Content in place of BrowserHost as described in the article. 

Strangely, you can achieve the same thing by removing the Width and Height tags on the main UserControl.  In the designer, this will make it appear as if the control is AutoSizing down to the contents of the subcontrols, but in the actual application it will take the full size of the browser if you have the height style set to 100% on body, form, and div of the containing element of the asp:Silverlight control as well as the Width and Height parameters set to 100% on the control itself.


Posted in Uncategorized | 3 Comments »

Entity Framework Error 3002 / Error 3003

Posted by Michael Bray on October 14, 2008

Fun problem I had today figuring out this error….  I suppose it is common, and in fact I think I recall reading posts on Usenet about this, without many solutions.  The problem comes when you have a mapping from one table to another. 

The error in this case comes in the form of two errors during compile:

Error 3002: Problem in Mapping Fragment starting at line 498: Potential runtime violation of table QuotePricedLineItem’s keys (QuotePricedLineItem.ObjectId): Columns (QuotePricedLineItem.ObjectId) are mapped to EntitySet FK_QuoteLineItem_QuoteVendorLineSet’s properties (FK_QuoteLineItem_QuoteVendorLineSet.QuoteVendorLineSet.ObjectId) on the conceptual side but they do not form the EntitySet’s key properties (FK_QuoteLineItem_QuoteVendorLineSet.QuotePricedLineItem.ObjectId, FK_QuoteLineItem_QuoteVendorLineSet.QuoteVendorLineSet.ObjectId).

Error 3003: Problem in Mapping Fragment starting at line 498: At least one of the key properties of AssociationSet FK_QuoteLineItem_QuoteVendorLineSet must be mapped to all the key properties (QuotePricedLineItem.ObjectId) of table QuotePricedLineItem.

This clearly sounds like there is a problem in the association between two tables.  Looking at the designer diagram, you see the relation:


and looking at the mappings of the association, at first glance, everything looks fine:


The problem lies in which column is mapped to which property.  In this case, and I believe generally in the case of this particular error, the columns are interchanged.  The mappings should be QuoteVendorLineSet.ObjectId = fkQuoteVendorLineSet, and QuotePricedLineItem.ObjectId = ObjectId.  This is obvious since the map is for QuotePricedLineItem, so ObjectId should map to itself.

The odd part is that this association was generated by the EF Designer wizard, so it is the one that screwed up.  At first I thought maybe I had the relationship backwards in the database, but that wasn’t the case.  Thus I’m not sure why this occurred, but tracking it down hopefully will be easier next time.

Posted in Uncategorized | 2 Comments »