Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
"A dependent property in a ReferentialConstraint is mapped to a storage-generated column. Column: 'employee_id'."}
C#
var emp_assigment = new EMPLOYEES_ASSIGNMENT
                                        {
                                            from_date = gvRowAssigment.Cells[0].ToString(),
                                            to_date = gvRowAssigment.Cells[1].ToString(),
                                            area = gvRowAssigment.Cells[2].ToString(),
                                            sector = gvRowAssigment.Cells[3].ToString(),
                                            company_name = gvRowAssigment.Cells[4].ToString(),
                                            description = gvRowAssigment.Cells[5].ToString(),

                                            
                                            employee_id = emp.employee_id,
                                            assigment_id = new Random().Next(),
                                            
                                            
                                            EMPLOYEES_ASSIGMENT_TOOLS = emp_assig_tools,

                                            assigment_tools_id =   emp_assig_tools.assigment_tools_id,
                                            
                                            EMPLOYEES_ASSIGMENT_TECHNOLOGY = emp_assig_teh,
                                            assigment_technology_id = emp_assig_teh.assigment_technology_id,
                                            
                                            EMPLOYEES_ASSIGMENT_REFERENCE = emp_assig_ref,
                                            reference_id = emp_assig_ref.reference_id
                                        };


                emp.EMPLOYEES_ASSIGNMENT.Add(emp_assigment);
 }


// i dont now what u mean?
here is a image of the piece of database im working with
http://tinypic.com/view.php?pic=20hlovs&s=6[^]
Posted
Updated 22-Mar-13 4:53am
v2

1 solution

The code you posted has nothing to do with the problem. It's probably due to you screwing up the relationship between two tables, invloving the employee_id column of one of the tables.

Did you accidentally tell EF that an autonumber column in the database is a Foreign Key column??
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900