Monday 23 April 2012

EF4.x: A dependent property in a ReferentialConstraint is mapped to a store-generated column

Next time, if I see this error again "A dependent property in a ReferentialConstraint is mapped to a store-generated column..." I will look into my Foreign Key constraint in SQL table design rather than looking for a solution within the codebase itself!

If foreign key relationship is pointing to wrong column of the table, you might lose your precise development time and mood.

E.g.
Employee (EmpID [PK], FName, Surname) 
Qualification(QualID [PK], EmpID [FY], QName, GraduationYear)

Careless mistake like - Instead of EmpID of Qualification table, you make QualID having FK relationship with EmpID of Employee table. BOOM!!!

No error during Entity Diagram generation but when you try to insert record into Qualification table with EmpID value that does not exist in Employee table, you will be presented with the above runtime error.


Cheers,
Milan Gurung



2 comments: