This project is read-only.

Getting error while inserting data in junction table

Nov 19, 2010 at 6:30 AM


I am using nHydrate to generate business layer in my project. It was working fine to insert/update data in junction table previously but after downloading latest version I am getting foreignkey reference error.

Here is detail of problem:

I have two master tables of PropertyMaster(PropertyId, and otherfields) and Amenities(AmenitiesId, otherfields) and junction table PropertyAmenities(PropertyAmenitiesId (pk), PropertyId (FK), AmenitiesId(FK).

While inserting record in PropertyAmenities table, I am getting error: ForeignKeyReferencial Integrity Error: PropertyId (-1) must be exist in parent table.

Previously it was working fine.

Please help me.

Nov 20, 2010 at 2:50 AM

Are you sing NHDAL or EFDAL? Also are you addressing the table manually (which you shoul dnot do really) or using the PropertyMaster.AmentiesList and the Amenities.PropertyMasterList syntax? Is it possible for you to send the code to me at The model, code, sample or something would be very helpful.

Nov 24, 2010 at 8:30 AM


No updates from your side!!!




Nov 25, 2010 at 5:55 PM

You must add the "PropertyMaster" object to its parent collection before you add the "Amenity" object to its collection. The "Property" object is the parent and the "Amenity" object is the child. So the parent must be in the collection first.