p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   Ch 14: Try it Out p. 511 - error 'dependent property in a ReferentialConstraint' (http://p2p.wrox.com/showthread.php?t=85592)

jayinatlanta November 5th, 2011 10:46 AM

Ch 14: Try it Out p. 511 - error 'dependent property in a ReferentialConstraint'
 
Here's another error I can't trace. I checked the forum and couldn't find anything like it.

On this one, VS generates no errors. I'm able to get all the way through entering a new album, AND information on a new "picture." Then I get this nasty stuff:

Error: A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'

Code:

[InvalidOperationException: A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'.]
  System.Data.Mapping.Update.Internal.UpdateCompiler.BuildSetClauses(DbExpressionBinding target, PropagatorResult row, PropagatorResult originalRow, TableChangeProcessor processor, Boolean insertMode, Dictionary`2& outputIdentifiers, DbExpression& returning, Boolean& rowMustBeTouched) +7529061
  System.Data.Mapping.Update.Internal.UpdateCompiler.BuildInsertCommand(PropagatorResult newRow, TableChangeProcessor processor) +122
  System.Data.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler) +432

[UpdateException: An error occurred while updating the entries. See the inner exception for details.]
  System.Data.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler) +616
  System.Data.Mapping.Update.Internal.<ProduceDynamicCommands>d__0.MoveNext() +725
  System.Linq.<ConcatIterator>d__71`1.MoveNext() +359
  System.Data.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator) +233
  System.Data.Mapping.Update.Internal.UpdateTranslator.ProduceCommands() +161
  System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) +222
  System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) +163
  System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) +657
  System.Web.UI.WebControls.EntityDataSourceView.ExecuteInsert(IDictionary values) +559
  System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +81
  System.Web.UI.WebControls.ListView.HandleInsert(ListViewItem item, Boolean causesValidation) +382
  System.Web.UI.WebControls.ListView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +657
  System.Web.UI.WebControls.ListView.OnBubbleEvent(Object source, EventArgs e) +227
  System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
  System.Web.UI.WebControls.ListViewItem.OnBubbleEvent(Object source, EventArgs e) +112
  System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
  System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
  System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +159
  System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +39
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3765

I went back and checked all the steps of this try-it-out, including regenerating the listview, making sure I had deleted the right portions of code, making sure the Where statement was correct, etc.

Where should I look?

Thanks,

Jay

Imar November 5th, 2011 11:35 AM

Hard to tell wihtout seeing the code or model but my guess is that you have a problem with the database. Maybe you didn't map the correct columns when defining primairy and foreign keys?

Check the database, and then recreate the model to see if that's the case.

Cheers,

Imar

jayinatlanta November 6th, 2011 12:32 AM

Yep, you're right, of course. I had related the Id to Id, rather than the Id to the PhotoAlbumId. On a side note, neither the diagram nor the model therefore could determine that there was a 1:M relationship in place.


All times are GMT -4. The time now is 03:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.