Last post Jun 08, 2009 12:09 PM by ricka6
May 14, 2009 05:35 PM|jzpy8l|LINK
I am having an issue when I try to access foreign key relationships from my gridview. I am using EF and have a database model that is built on primary/foreign key references with different names (i.e. Library.pkLibraryID : LibraryGroupMembers.fkLibraryID).
Currently when I click on the LibraryGroupMembers hyperlink in the Libraries view I get the following error in the ForeignKey.ascx.cs page when returning ForeignKeyPath: DataBinding: 'ProductAdmin.Models.Libraries' does not contain a property with the name
'fkLibraryID'. This is true as I would assume I would want to pass the pkLibraryID. I am not sure if I need to rename a column in my metadata or how to go about this. Thanks for any guidance.
May 14, 2009 06:28 PM|sjnaughton|LINK
This is a bug in Ef you will need the workaround
here see this section Dynamic Data Fix for Entity Framework
EF Work Around
May 15, 2009 10:25 AM|jzpy8l|LINK
Downloaded the updates to the framework and still getting the same issue. It seems that if my primary key and foreign key are not named the same, the reference does not act appropriately.
May 15, 2009 11:22 AM|sjnaughton|LINK
I have had the same issue and it fixed it for me PK and FK different i.e. Order table PK=ID and OrderLines table FK=OrderID. Now it works, there must be some other issue have you tried with Northwind first to make sure everything is OK and not some other
May 15, 2009 04:23 PM|jzpy8l|LINK
OK, now I'm confused. Added a new EF model for Northwind, created a new DomainService that references the Northwind model and everything works fine (even the Orders.ShipVia to Shipping.ShippingID reference). Do a compare in the model and DomainService metadata
between the Northwind setup and my setup and looks like it should act appropriately. When I navigate in my model/domainservice I continue getting errors whenever trying to access foreign key references (ex. DataBinding: 'ProductAdmin.Models.Designs' does not
contain a property with the name 'fkDesignID'.) My Designs table does not contain a fkDesignID column, only a pkDesignID column. Not sure why it's trying to reference this.
My original and Northwinds example are running from the same project.
Thanks for any help.
May 15, 2009 05:05 PM|sjnaughton|LINK
Check the bin folder you may have some erroneous DLLs in there [:D]
Jun 07, 2009 11:05 PM|slashnick|LINK
I am having this exact problem and I'm using the same DLLs that came with Dynamic Data Preview 4.
Jun 08, 2009 03:21 AM|sjnaughton|LINK
When using a GUID you will need to create the GUID and set the value in the Inserting event in L2S and via the
http://msdn.microsoft.com/en-us/library/cc716714.aspx in EF
Jun 08, 2009 12:09 PM|ricka6|LINK
re GUIDs: From
Dynamic Data FAQ
Q: How do I generate GUIDs on inserts?
A: You don't, you shouldn't. Let the DB generate them or you will have performance problems. You can modify the data model XML and explicitly state they are DB generated. With the EDM, use StoreGeneratedPattern="Computed" while Linq
to SQL uses IsDbGenerated="true"