IEditableCollectionView.AddNew() Throwing ArgumentNullException
- by Eugarps
In the context of Silverlight RIA using DomainContext and, the code as follows:
private void AddProductButton_Click(object sender, RoutedEventArgs e)
{
var target = (Web.LocatorProduct)((IEditableCollectionView)ProductSource.DataView).AddNew();
target.Locator = LocatorID;
target.Product = NewProduct.Text.ToUpper();
((IEditableCollectionView)ProductSource.DataView).CommitNew();
}
Is throwing ArgumentNullException in AddNew(), CreateIdentity() further up on the stack (a generated method) due to product being null. Product and LocatorID are, in combination, the primary key.
I'm guessing that EF is not allowing me to generate a new item without meeting database contraints? How does this make sense if I need to obtain a primary key from the user?
I have control over all tiers of the application, so suggestions on database design if needed are also welcomed.